You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Include verified repair file edits when TrueForge returns an incomplete changed-file payload.
Support verified unified-diff repairs in changed-file enrichment.
Reject manifest-only npm/pnpm upgrade PRs when the expected lockfile is missing.
Support creating new files during GitHub PR file writes by omitting sha for missing paths.
Preserve package manager on upgrade run snapshots for PR safety checks.
Agent changes
src/lib/trueforge.ts: enriches verified repair results with all repaired files, including text replacements, full-file replacements, and unified diffs; fails the repair handoff instead of persisting partial verified evidence when enrichment cannot safely recover a touched file.
src/lib/upgrade-run-store.ts: carries package-manager metadata through upgrade run snapshots so PR safety checks know which lockfile is required.
src/app/api/repositories/upgrade-runs/pull-request/route.ts: blocks unsafe manifest-only dependency PRs and generates PR descriptions with agent changes, verification evidence, and remaining risk.
src/lib/github.ts: supports both updating existing files and creating new files in generated upgrade PRs.
Test files: add regression coverage for multi-file PR payloads, unified-diff repair enrichment, enrichment failure handling, and GitHub create-vs-update behavior.
Verification
npm test -- src/lib/trueforge.test.ts src/lib/upgrade-run-store.test.ts src/app/api/repositories/upgrade-runs/pull-request/route.test.ts --runInBand
npm test -- src/lib/trueforge.test.ts src/lib/github.test.ts --runInBand
npm run typecheck
npm run lint
npm test
npm run build
git diff --check
Remaining risk
No known remaining risk after the focused regression coverage and local quality gates above.
This PR does not change the patched TrueForge server workflow itself; it hardens UpgradePilot against incomplete changedFiles payloads returned by that integration.
➕ Makes the verifier the single authoritative source of repaired file contents.
➕ Avoids default-branch GitHub reads and local text-replacement reconstruction.
➖ Requires an upstream TrueForge contract and deployment change.
➖ Does not protect callers from older or temporarily incomplete verifier payloads.
Recommendation: The current compatibility-layer approach is appropriate for an immediate safety fix: it preserves complete verifier output, fills only omitted repair paths, and blocks unsafe manifest-only PRs. A stricter TrueForge changed-files contract would be a useful follow-up, but should not replace the defensive validation added here.
Files changed (6) +206 / -11
Bug fix (3) +130 / -7
route.tsBlock unsafe manifest-only npm and pnpm upgrade PRs+22/-0
Block unsafe manifest-only npm and pnpm upgrade PRs
• Derives the expected lockfile from the recorded package manager and rejects PR creation when that file is absent. Existing verified files continue to be passed together to GitHub.
trueforge.tsEnrich verified results with omitted structured repair files+100/-7
Enrich verified results with omitted structured repair files
• Merges missing full-file replacements into verified changed files and reconstructs omitted text replacements from default-branch GitHub content. Deduplicates paths, applies only unambiguous text matches, and preserves available verifier results when source retrieval fails.
upgrade-run-store.tsPreserve package manager in every upgrade-run snapshot+8/-0
Preserve package manager in every upgrade-run snapshot
• Adds package-manager metadata to upgrade snapshots across running, blocked, interrupted, completed, and sanitized records. This enables downstream PR validation to select the correct lockfile requirement.
route.test.tsCover complete changed-file forwarding and missing-lockfile rejection+46/-3
Cover complete changed-file forwarding and missing-lockfile rejection
• Expands PR creation coverage to assert that manifest, lockfile, and repaired source files are all forwarded. Adds a regression test ensuring verified npm runs without package-lock.json return 409 and never call GitHub.
trueforge.test.tsVerify omitted text-repair files are reconstructed+29/-1
Verify omitted text-repair files are reconstructed
• Mocks GitHub repository metadata and source retrieval for a repaired file omitted by verification results. Confirms the successful handoff returns the fully repaired content in changedFiles.
includeVerifiedRepairFiles augments missing files only from structured file/text replacements and
never uses the supported repairPatch.unifiedDiff. When TrueForge's changed-file payload is
incomplete for a unified-diff repair, the verified source edits remain absent from the pull request.
The stated PR intent is incomplete verified files, but unified-diff repairs are plainly excluded.
ⓘ Recommendations generated based on similar findings in past PRs
Evidence
The repair prompt permits unified diffs, extraction retains them, and repair verification sends them
to TrueForge, but the new fallback enumerates only fileReplacements and textReplacements;
downstream PR creation uses only the resulting changedFiles.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
Verified repairs expressed as `unifiedDiff` are not added when TrueForge returns an incomplete `changedFiles` payload.
## Issue Context
The handoff contract explicitly supports unified diffs, and repair verification applies them, but enrichment considers only file and text replacements.
## Fix Focus Areas
- src/lib/trueforge.ts[556-635]
- src/lib/trueforge.ts[660-687]
- src/lib/trueforge.ts[1273-1285]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
2. Repair retrieval errors are swallowed✓ Resolved📘 Rule violation☼ Reliability
Description
includeVerifiedRepairFiles catches GitHub parsing, metadata, authorization, network, and
file-fetch failures and returns a partially enriched changedFiles result while retaining
VERIFIED, without an error signal. Callers may persist the run as verified and create an
incomplete pull request that silently omits repair files, or encounter only a later generic
conflict.
ⓘ Recommendations generated based on similar findings in past PRs
Evidence
Compliance rule 2919014 forbids catch handlers that neither rethrow, return an error result, nor log
actionable context, and rule 2919016 requires external-service flows to explicitly handle
authorization, timeout, malformed, and empty responses. The broad catch instead converts every
failure into the same successful-looking partial result; because the status remains VERIFIED, the
store records the accumulated files and the pull-request route forwards them directly to GitHub
without knowing enrichment failed.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
`includeVerifiedRepairFiles` silently converts GitHub parsing, metadata, authorization, network, and file-fetch failures into a partial `VERIFIED` changed-file list, allowing incomplete results to be persisted and submitted in a pull request.
## Issue Context
Do not discard enrichment failures. Distinguish expected missing files from authorization, timeout, malformed-response, empty-response, and other retrieval failures, and expose actionable operation and repository/path context by throwing, returning a blocked/error result, or using the project's structured logging mechanism. The run store currently persists the partial list because the run remains verified, and the pull-request route submits that list without knowing enrichment failed.
## Fix Focus Areas
- src/lib/trueforge.ts[601-634]
- src/lib/upgrade-run-store.ts[297-307]
- src/app/api/repositories/upgrade-runs/pull-request/route.ts[51-66]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
After deterministic verification succeeds, repair files are reconstructed from the repository's
movable default branch, while replacements whose old text is missing or non-unique are silently
skipped and unchanged files are omitted. The resulting PR payload can therefore be partial or
revision-mismatched relative to the sandbox-tested content while retaining VERIFIED, instead of
being blocked, failed, or re-verified.
ⓘ Recommendations generated based on similar findings in past PRs
Evidence
Compliance rule 2918965 requires success to derive from concrete execution artifacts, and rule
2918966 requires unsafe upgrades to be blocked. The cited code collects repair context and verifies
operations in the retained sandbox, but enrichment then fetches separate source bytes from
metadata.defaultBranch; the replacement helper skips missing or duplicated matches, the caller
includes a file only when the transformation changes its content, and the original VERIFIED status
is returned regardless, demonstrating that the PR payload can differ from what deterministic
verification tested.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
Post-verification reconstruction can produce partial or revision-mismatched PR file contents because text replacements that cannot be applied exactly are silently skipped while the result remains `VERIFIED`.
## Issue Context
Replacement context comes from the retained, verified sandbox, but reconstruction reads current content from the movable GitHub default branch. Ensure that the exact bytes submitted in the PR are the bytes tested by deterministic verification; a missing or duplicated match must invalidate enrichment rather than omit the edit, and any payload that cannot be reconstructed exactly should return a blocked/failed result or be re-verified.
## Fix Focus Areas
- src/lib/trueforge.ts[556-634]
- src/lib/trueforge.ts[641-657]
- src/lib/trueforge.ts[1339-1356]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
4. New repair files cannot commit✓ Resolved🐞 Bug≡ Correctness
Description
The new enrichment path appends every missing full-file replacement, including a replacement path
that does not yet exist, but GitHubClient.createPullRequest requires an existing file SHA before
every write. A verified repair that creates a file consequently fails during pull-request creation
on the initial 404 lookup.
+ for (const replacement of input.repairPatch.fileReplacements) {+ if (!includedPaths.has(replacement.path)) {+ changedFiles.push({ path: replacement.path, content: replacement.content });+ includedPaths.add(replacement.path);
Relevance
●●● Strong
Missing-file creation failure is a concrete correctness bug in the new verified-file path.
ⓘ Recommendations generated based on similar findings in past PRs
Evidence
The repair response schema accepts arbitrary repository-relative replacement paths and the new code
adds absent paths. PR creation then performs an unhandled existing-file GET and unconditionally
reads its SHA, while the shared JSON requester throws on 404 before the PUT can occur.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
Enriched full-file replacements can reference new files, but pull-request creation only supports updating existing files.
## Issue Context
GitHub file creation must omit `sha` when the target path does not exist, while updates must continue supplying the existing SHA.
## Fix Focus Areas
- src/lib/trueforge.ts[582-587]
- src/lib/github.ts[145-165]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
The PR description contains Summary and Verification but no non-empty remaining-risk section and
no explicit agent-change section listing each modified application component. Because this PR
changes application code, both required description elements must be added.
Explicit repository rules require both sections; omission is a straightforward documentation
compliance issue.
ⓘ Recommendations generated based on similar findings in past PRs
Evidence
The supplied PR description has change and verification sections but lacks any remaining-risk
section. It also lacks a clearly labeled agent-change summary naming the modified application
components, while the cited changed production files establish that application code was modified.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
The pull request description is missing the required `Remaining risk` and explicit `Agent Changes` sections.
## Issue Context
Add non-empty known risks or state that none are known, and list each modified application component with its purpose, including the pull-request route, TrueForge integration, and upgrade-run snapshot storage.
## Fix Focus Areas
- src/lib/trueforge.ts[556-562]
- src/app/api/repositories/upgrade-runs/pull-request/route.ts[39-46]
- src/lib/upgrade-run-store.ts[22-25]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
shafor missing paths.Agent changes
src/lib/trueforge.ts: enriches verified repair results with all repaired files, including text replacements, full-file replacements, and unified diffs; fails the repair handoff instead of persisting partial verified evidence when enrichment cannot safely recover a touched file.src/lib/upgrade-run-store.ts: carries package-manager metadata through upgrade run snapshots so PR safety checks know which lockfile is required.src/app/api/repositories/upgrade-runs/pull-request/route.ts: blocks unsafe manifest-only dependency PRs and generates PR descriptions with agent changes, verification evidence, and remaining risk.src/lib/github.ts: supports both updating existing files and creating new files in generated upgrade PRs.Verification
npm test -- src/lib/trueforge.test.ts src/lib/upgrade-run-store.test.ts src/app/api/repositories/upgrade-runs/pull-request/route.test.ts --runInBandnpm test -- src/lib/trueforge.test.ts src/lib/github.test.ts --runInBandnpm run typechecknpm run lintnpm testnpm run buildgit diff --checkRemaining risk
changedFilespayloads returned by that integration.