feature: graceful fallback to timestamp based diff on unreachable gitHead#385
Open
Joseph Zhang (jzhn) wants to merge 1 commit into
Open
feature: graceful fallback to timestamp based diff on unreachable gitHead#385Joseph Zhang (jzhn) wants to merge 1 commit into
Joseph Zhang (jzhn) wants to merge 1 commit into
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
After each run, OpenWiki records the HEAD SHA in
openwiki/.last-update.jsonand diffsgit log <gitHead>..HEADto find what changed since the last update. When git history is rewritten with squash or rebase, the recorded SHA becomes orphaned (no longer reachable from HEAD) — or is absent entirely on a fresh/shallow clone.When that happens, OpenWiki silently misbehaves:
runGit()swallows git's non-zero exit and returns thefatal: Invalid revision range …text as if it were normal output.getUpdateNoopStatus) only "worked" by accident — it misinterpreted the error string as a changed path.createGitSummary) fed the model thefatal:string as its diff, and the timestamp fallback was structurally unreachable: theif/else-ifwas keyed on whethergitHeadwas present, not on whether the git command succeeded.Net effect: incremental updates run blind (under-update or hallucinate) with no signal that anything went wrong.
Solution
Detect an unreachable baseline explicitly and degrade gracefully:
commitExists(cwd, sha)(git cat-file -e <sha>^{commit}).getUpdateNoopStatus: if the recordedgitHeadisn't reachable, return "not a no-op" with a clear reason instead of parsing git's error text — safe default is to run the update.createGitSummary: guard thegitHead..HEADbranch withcommitExists. If the commit is gone, fall through to the existing time-basedgit log --since <updatedAt>evidence and prepend an explicit note. The model never receives afatal:string again.Alternatives considered
.last-update.json(the approach in our CI workaround).git log -1 --format=%H -- .last-update.jsonis always reachable (log only walks HEAD's ancestors) and is a more precise incremental baseline than a timestamp. Not chosen for the core fix because of too much added complexity.runGitfail loudly / distinguish "empty diff" from "command failed." Correct as defense-in-depth, but larger blast radius across all git calls; thecommitExistsguards prevent the bad range from ever running, so it's deferred.Notes
Before this is merged, my team is using below to "repair" the gitHead in our CI setup.