fix(sync): clean up stale context.expanded.md when markers removed#21
Merged
Conversation
When a pack's context.md loses all its <!-- sync:fetch --> markers, runMarkerExpansion previously returned early without touching the existing context.expanded.md. Because the loader prefers context.expanded.md over context.md, sync+inject would keep serving the stale fetched content indefinitely. The fix deletes the previously-written context.expanded.md for any pack that no longer has markers, so the loader falls back to the fresh context.md.
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.
Summary
context.mdloses all its<!-- sync:fetch ... -->markers, the previously-writtencontext.expanded.mdwas never deleted. Because the loader preferscontext.expanded.mdovercontext.md,sync+injectkept serving stale fetched content indefinitely.runMarkerExpansionnow deletes the orphanedcontext.expanded.mdfor any pack that no longer has markers, so the loader falls back to the freshcontext.md.removeStaleExpansionhelper plus three unit tests covering: file is deleted, no-file-is-not-an-error, siblingcontext.mdis left untouched.CLAUDE.mdanddocs/content-authoring.mdso pack authors can rely on it.Repro (before the fix)
<!-- sync:fetch ... -->marker to a pack'scontext.mdand runsap-devs sync.context.mdand runsap-devs syncagain.sap-devs injectstill includes the fetched content becausecontext.expanded.mdis preferred and was never cleaned up.Test plan
go build ./...go vet ./...go test -c ./cmd/(compiles; execution blocked locally by Windows Defender per the documented gotcha — CI runs them)ubuntu-latestcontext.expanded.md; nextinjectuses freshcontext.md