Commit Graph

2 Commits

Author SHA1 Message Date
vasilito 687b2650be phase 6.4: operator-decision automation in verify-patch-content
Adds --report action mode to verify-patch-content.py that implements
the AGENTS.md § 'Orphan-Patch Supersession Decision Tree' algorithmically.

For each orphan, the action recommender outputs one of:
  - INTEGRATED:      fork log has >5 commits matching topic keywords;
                    the work IS in the fork under a different commit
                    subject. Safe to archive as superseded.
  - FILE-RESTRUCTURED: target file no longer exists in fork (file
                    rebased past patch's expectations). Safe to archive.
  - NO-TARGET-FILE:  patch lacks +++ b/ header (non-actionable).
                    Safe to archive.
  - MISSING-UPSTREAM: work NOT in fork; needs reapply or fork rebase.

Algorithm (in suggest_action_for_orphan):
  1. Check if patch has no target file (lacks +++ b/) → NO-TARGET-FILE
  2. Check if target file no longer exists in fork → FILE-RESTRUCTURED
  3. Run 'git log -i --grep <topic-keyword>' on the fork; if >5 commits
     match → INTEGRATED
  4. Otherwise → MISSING-UPSTREAM

Validated with synthetic test: created a local/patches/relibc/
_test-synthetic-orphan.patch with target=lib/test/strange.rs (which
doesn't exist in fork). The recommender correctly classified it as
FILE-RESTRUCTURED.

Wired into pre-push-checks.sh as check #3a (verify-patch-content-action).
Future new orphans are auto-classified; the operator only needs to
verify the suggested classification matches reality and then archive
to legacy-superseded-2026-07-12/.
2026-07-12 10:43:15 +03:00
vasilito e4bb452d86 phase 1.0B: add verify-patch-content.{py,sh} — orphan-patch audit tool
Per the Phase 1.0 audit (local/docs/PATCH-PRESERVATION-AUDIT-2026-07-12.md)
no part of the build system was checking that patches listed in
local/patches/<comp>/ had actually been absorbed into the
local/sources/<comp>/ fork's working tree.

This commit adds a tool that audits every Cat 2 fork and reports any
patches whose content is not present in the fork HEAD. The tool is
located at local/scripts/verify-patch-content.{sh,py} and follows the
existing local/scripts/ convention (shell wrapper delegating to
Python implementation).

Audit method:
  1. For each .patch in local/patches/<comp>/:
     - Extract target file from ---/+++ headers
     - Extract first 5 added lines (+ markers)
     - Check substring presence in fork HEAD version
  2. If 0/5 added lines found, patch is 'orphaned'

Current state (after Phase 1.0A recovery):
  - 251 patches total, 155 preserved, 96 still orphaned
  - The remaining orphans are patches where the upstream file structure
    has shifted too far for patch(1) to apply — those need
    upstream-tracking upgrade, deferred to Phase 2.

Usage:
  ./local/scripts/verify-patch-content.sh                       (report)
  ./local/scripts/verify-patch-content.sh --strict             (exit 1 on orphans)
  ./local/scripts/verify-patch-content.sh base kernel          (specific forks)

Wired in via build-preflight.sh in the next commit (Phase 1.0B cont.).

This closes the 'silent patch loss' gap identified in the audit.
2026-07-12 01:31:03 +03:00