* test(#4136): failing-first rows for the unreachable incorporated status Folded block bug-4136-reapply-incorporated-status locks the --classify contract (incorporated / needs_merge / unknown, never-incorporated guards, cycle end-to-end) plus the workflow-contract rows; REASON gains OK_UNVALIDATED_BASELINE in both shape-locks; the #2994 invocation count moves 1 -> 2 (classify + gate). All red until the verifier grows --classify and the workflow consumes it. * fix(#4136): compute the incorporated status; stop re-grafting superseded patches Add --classify pre-merge mode to the deterministic verifier: with a hash-validated pristine baseline, a file whose every significant user-added line is already present verbatim in the freshly installed version is classified incorporated (new frozen CLASSIFICATION enum, structured --json report, always exit 0 — the binding gate stays the post-merge run). Drifted (#3657), absent (#934), unvalidated (new OK_UNVALIDATED_BASELINE), and no-baseline runs classify unknown — a false incorporated silently retires a live customization, so only a confirmed baseline may ever confirm adoption. The baseline-resolution block moves out of verifyFile into a shared resolvePristineBaseline so the gate and the classifier cannot drift on what counts as a usable baseline; gate behavior is byte-identical. reapply-patches.md step 4 gains the pre-flight classifier invocation and the not-re-grafted contract: incorporated files are left exactly as shipped (their hash then re-converges with the manifest, ending the backup cycle), statuses feed steps 3/7, and the merge rules gain the already-present-verbatim arm. Emitted-Drift-Ack-Growth: reapply-patches.md — step 4 pre-flight classifier section, the documented Incorporated status needed its deterministic contract * fix(#4136): address review findings on the workflow contract Drop the unused INCORPORATED_COUNT shell variable (standards pass) and close the all-files-incorporated gap in the hunk-table guidance: emit a header row plus a note line so the step 5b absent-table halt is not tripped when nothing was merged (spec pass). Emitted-Drift-Ack-Growth: reapply-patches.md — step 4 pre-flight classifier section, the documented Incorporated status needed its deterministic contract * chore(#4136): backfill changeset fragment with PR 4373 * test(#4136): lock that a 4145-recovered baseline can confirm incorporation The hash-first orphan recovery merged with next (PR #4364) lands in the shared resolvePristineBaseline as a validated resolution; this row pins the composition so a future change cannot quietly downgrade recovered baselines to unknown and silently disable incorporated detection for prefix-less installs. --------- Co-authored-by: sim <sim@local>
This commit is contained in:
@@ -192,6 +192,58 @@ If neither git history nor pristine snapshots are available, fall back to two-wa
|
||||
|
||||
## Step 4: Merge each file
|
||||
|
||||
### Step 4 pre-flight: classify superseded customizations (#4136)
|
||||
|
||||
Before merging anything, run the deterministic classifier. It computes, per backed-up file,
|
||||
whether the user's added lines (diff of the backup against the hash-validated pristine
|
||||
baseline) are ALREADY present verbatim in the newly installed version — i.e. upstream
|
||||
adopted the customization. That is the only ground on which the `Incorporated` status
|
||||
below is valid. Never conclude `Incorporated` from a signature line, a heading, or general
|
||||
resemblance: the classifier excludes structural/trivial lines and requires every
|
||||
significant user-added line to be present, because a false `Incorporated` silently retires
|
||||
a live customization.
|
||||
|
||||
```bash
|
||||
PRISTINE_DIR="${CONFIG_DIR}/gsd-pristine"
|
||||
|
||||
# Build args as a bash array so paths with spaces survive expansion intact.
|
||||
CLASSIFY_ARGS=(
|
||||
--patches-dir "$PATCHES_DIR"
|
||||
--config-dir "$CONFIG_DIR"
|
||||
)
|
||||
if [ -d "$PRISTINE_DIR" ]; then
|
||||
CLASSIFY_ARGS+=(--pristine-dir "$PRISTINE_DIR")
|
||||
fi
|
||||
CLASSIFY_ARGS+=(--classify --json)
|
||||
|
||||
# Informational: exits 0. The binding gate is Step 5a's post-merge verification run.
|
||||
CLASSIFY_OUTPUT="$(node "${GSD_HOME}/gsd-core/bin/verify-reapply-patches.cjs" "${CLASSIFY_ARGS[@]}")"
|
||||
INCORPORATED_FILES="$(echo "$CLASSIFY_OUTPUT" | node -e "const d=JSON.parse(require('fs').readFileSync('/dev/stdin','utf8'));(d.incorporated_files||[]).forEach(f=>process.stdout.write(f+'\n'))")"
|
||||
```
|
||||
|
||||
**For every file in `INCORPORATED_FILES`:**
|
||||
|
||||
- **Do NOT merge it. Do NOT re-apply its diff.** Leave the newly installed file exactly as
|
||||
shipped — the user's customization is already in it. Re-grafting the diff onto a version
|
||||
that already contains it duplicates the content (both copies run; a stale graft can
|
||||
contradict a richer native upstream step that replaced it).
|
||||
- Report the per-file status `Incorporated` — "Already in upstream v{version}" — in the
|
||||
Step 3 summary and the Step 7 report.
|
||||
- No Hunk Verification Table rows are required for these files (nothing was merged); the
|
||||
classifier's structured output is the evidence. If EVERY backed-up file is Incorporated,
|
||||
still emit the table with a header row and a single note line naming the incorporated
|
||||
files, so the Step 5b absent-table halt is not tripped. Step 5a passes these files
|
||||
without special-casing — every user-added line is present in the untouched install.
|
||||
- This is what ends the re-graft cycle: because the installed file stays identical to what
|
||||
the release ships, the next update's hash comparison no longer flags it as modified, and
|
||||
the file drops out of `gsd-local-patches/` on the next cycle.
|
||||
|
||||
Files NOT in `INCORPORATED_FILES` — reported `needs_merge` (with the lines still missing
|
||||
from the new version) or `unknown` (no confirmable pristine baseline) — take the normal
|
||||
merge paths below, unchanged. If the classifier cannot run at all (e.g. `GSD_HOME`
|
||||
unset), fall back to merging every file as before; never report `Incorporated` without the
|
||||
classifier's structured confirmation.
|
||||
|
||||
For each file in `backup-meta.json`:
|
||||
|
||||
1. **Read the backed-up version** (user's modified copy from `gsd-local-patches/`)
|
||||
@@ -209,6 +261,9 @@ Compare the three versions to isolate changes:
|
||||
- Sections changed only by upstream → accept upstream version
|
||||
- Sections changed by both → flag as CONFLICT, show both, ask user
|
||||
- Sections unchanged by either → use new version (identical to all three)
|
||||
- User-added content already present verbatim in the new version → already incorporated
|
||||
upstream — do NOT re-apply it (the file-level outcome is `Incorporated` when ALL
|
||||
user-added content is thus present, as determined by the Step 4 pre-flight classifier)
|
||||
|
||||
### Two-way merge (fallback when no baseline)
|
||||
|
||||
@@ -265,7 +320,7 @@ After writing each merged file, verify that user modifications survived the merg
|
||||
6. **Report status per file:**
|
||||
- `Merged` — user modifications applied cleanly (show summary of what was preserved)
|
||||
- `Conflict` — user reviewed and chose resolution
|
||||
- `Incorporated` — user's modification was already adopted upstream (only valid when pristine baseline confirms this)
|
||||
- `Incorporated` — user's modification was already adopted upstream (only valid when pristine baseline confirms this — determined exclusively by the Step 4 pre-flight classifier's `incorporated_files`, never by inspection)
|
||||
|
||||
**Never report `Skipped — no custom content`.** If a file is in the backup, it has custom content.
|
||||
|
||||
@@ -439,6 +494,7 @@ Ask user:
|
||||
- [ ] No file classified as "no custom content" or "SKIP" — every backed-up file is definitionally modified
|
||||
- [ ] Three-way merge used when pristine baseline available (git history or gsd-pristine/)
|
||||
- [ ] User modifications identified and merged into new version
|
||||
- [ ] Superseded customizations classified `Incorporated` by the deterministic pre-flight classifier (pristine-confirmed) and not re-grafted
|
||||
- [ ] Conflicts surfaced to user with both versions shown
|
||||
- [ ] Status reported for each file with summary of what was preserved
|
||||
- [ ] Post-merge verification checks each file for dropped hunks and warns if content appears missing
|
||||
|
||||
Reference in New Issue
Block a user