reconcile: harden replayLocalOntoRemote against merge commits + empty commits
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 68/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Tranquilo
- Stack tecnológico
- git, typescript
Línea de trabajo
Empieza en apps/api/src/store/reconcile.ts, en replayLocalOntoRemote, y después lee los casos de reconciliación existentes en apps/api/tests/data-repo-reconcile.test.ts. Añade cobertura para los commits de merge locales y los commits vacíos usando los resultados propuestos, y ejecuta ese archivo de pruebas. Se considera terminado cuando los commits de merge escapan con el hash en el registro de conflictos y los commits vacíos están ausentes del historial reescrito.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Background
PR #86's replayLocalOntoRemote (in apps/api/src/store/reconcile.ts) replaces git rebase with a per-commit merge-tree --write-tree + commit-tree loop. The plan's Risks section flags two edge cases that the implementation accepts silently rather than guarding against:
1. Merge commits get silently flattened
'commit-tree', mergedTreeHash, '-p', newTip, '-m', message
Single -p parent. If a multi-parent commit ever appears in localCommits, the replay collapses it into a single-parent commit. git rebase by default refuses to replay merges (errors out); --rebase-merges preserves them.
Risk: the data repo today is all programmatic single-parent gitsheets transacts, so this never fires. But if a human or a future automation ever lands a merge commit on the data repo, reconcile would silently drop one of the parents and rewrite history in a misleading way.
2. Empty commits are preserved instead of dropped
git commit-tree <existing-tree> happily writes a commit even when the resulting tree equals the parent's tree (no diff). Modern git rebase drops empty commits by default (--no-empty). The replay loop currently writes them through.
Risk: an empty commit (programmatically possible if a gitsheets transact does nothing but still commits) gets preserved across reconcile, making history noisier than git rebase would produce.
Proposed hardening
In replayLocalOntoRemote:
- Reject merge commits early. Before the loop, check each commit's parent count via
git rev-list --parentsorgit cat-file -p <commit> | head -1. If any commit has>1parent, throwRebaseReplayConflictError(routes to the escape-hatch) with a clear message. Operator can then investigate the unexpected merge commit onconflicts/<UTC>. - Skip empty commits. Before calling
commit-tree, comparemergedTreeHashto the new tip's tree (git show <newTip> --format=%T -s). If equal, skip the commit and continue withnewTipunchanged.
Both checks are cheap. The merge-commit guard is the more important one (data loss avoidance); the empty-commit skip is purely a history-cleanliness improvement.
Tests to add
In apps/api/tests/data-repo-reconcile.test.ts:
- New case: diverged-with-merge-commit-on-local → expect
outcome: 'conflict-escaped'with the merge commit's hash mentioned in the conflict log. - New case: diverged-with-empty-commit-on-local → expect
outcome: 'rebased', empty commit dropped from the rewritten history.
Why post-cutover
Neither edge case is reachable from current code paths (no merge commits, no empty-commit-producing transacts). Filing as hardening rather than a bug fix.
Filed as follow-up from PR #86.
- Lenguaje dominante
- TypeScript
- Estrellas
- 1
- Forks
- 1
- Merge medio
- 1 d 20 h
- PR fusionados (30 d)
- 25
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de CodeForPhilly/codeforphilly-ng
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
-
MarkdownEditor toolbar: use Radix Toolbar from radix-ui instead of the hand-rolled roving tabindex Abiertoenhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Todos los issues de CodeForPhilly/codeforphilly-ng
Issues similares
-
bug(cli): hapi doctor inline-media prints a fabricated B:\ helper-script path in packaged installs Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
Crush Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
catppuccin/catppuccin#3125 ·
-
Add a SECURITY.md Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
ElementsProject/cln-application#167 · 1 comentario · 1 reacción ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Quantco/pnpm-licenses#17 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100