Skip to content

cve_corrector: fix devtool finish failures#20

Open
danielturull wants to merge 5 commits into
mainfrom
fix/incremental
Open

cve_corrector: fix devtool finish failures#20
danielturull wants to merge 5 commits into
mainfrom
fix/incremental

Conversation

@danielturull

Copy link
Copy Markdown
Contributor

Summary

Two fixes for devtool finish failures observed during CVE backporting:

  1. Detached HEAD checkdevtool finish commits into the target meta-layer, which requires HEAD to be on a branch. Add a pre-flight check that raises GitError with an actionable message instead of a cryptic failure at exit code 7.

  2. Reset modified tracked files — After devtool build, autotools-regenerated files (Makefile.in, etc.) dirty the working tree. devtool finish -f proceeds past the warning but crashes with FileNotFoundError when exporting files to a temp dir missing parent subdirectories. Add git checkout . to restore tracked files before finish.

Testing

  • Added tests/corrector/test_ensure_layer_branch.py with tests for both on-branch and detached HEAD scenarios
  • All CI passes: ruff, mypy, pytest (647 passed, 73.86% coverage)

- Add _merge_results() to preserve data from inactive sources when
  reprocessing CVEs incrementally, deduplicating by hash/url and
  combining source strings
- Add _accumulate_stats() to correctly count per-source statistics
  for both skipped and reprocessed entries
- Add retry with exponential backoff to Ubuntu API client, handling
  429 rate-limiting and transient failures (3 attempts, configurable
  base delay)
- Refactor extract_from_ubuntu_response() to use shared _process_url()
  helper, removing duplicated hash/PR extraction logic
- Add tests for retry exhaustion and 429 recovery

Assisted-by: kiro, claude-opus-4.6
Signed-off-by: Daniel Turull <daniel.turull@ericsson.com>
…inish

devtool finish commits into the target meta-layer, which requires HEAD
to be on a branch. A detached HEAD causes a cryptic 'Git operation
failed' error (exit 7) at the end of the workflow.

Add _ensure_layer_branch() pre-flight check that runs before devtool
finish and raises GitError with an actionable message telling the user
to checkout a branch.

Assited-by: Kiro, claude-opus-4.6
Signed-off-by: Daniel Turull <daniel.turull@ericsson.com>
After 'devtool build', autotools-regenerated files (Makefile.in, etc.)
are left modified in the workspace working tree. devtool finish -f
proceeds past the 'not clean' warning but then crashes with
FileNotFoundError when _export_local_files tries to copy these files
into a temp directory that lacks the parent subdirectory structure.

Add 'git checkout .' after 'git clean -fdx' to restore tracked files
to their committed state. The actual CVE fix is already committed on
the devtool branch, so this only discards build artifacts.

Assited-by: Kiro, claude-opus-4.6
Signed-off-by: Daniel Turull <daniel.turull@ericsson.com>
CVE_TOOLS_DATA_DIR was already honoured via data_dir() for tool-specific
paths but debian_tracker_dir, cvelistv5_dir, and nvd_dir fell back to
XDG_DATA_HOME, ignoring the override.

Check CVE_TOOLS_DATA_DIR before XDG_DATA_HOME so all data paths respect
the same environment variable.

Assisted-by: Kiro:claude-sonnet-4.6
Signed-off-by: Daniel Turull <daniel.turull@ericsson.com>
When the AI agent resolves conflicts, it sometimes replaces the original
upstream commit message body with backport notes instead of appending
them after it.

amend_commit_with_summary() now detects this case by checking whether
the first non-blank body line starts with a known backport note marker
(Backport Resolution:, Backport changes:, etc.). If so, it fetches the
original subject and body from the upstream SHA and reconstructs the
message: original content first, then the AI notes, then the summary.

Also update AGENT_INSTRUCTIONS.md to explicitly instruct the AI to
preserve the original MERGE_MSG content and only append notes after it.

Assisted-by: Kiro:claude-sonnet-4.6
Signed-off-by: Daniel Turull <daniel.turull@ericsson.com>
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