magic-context icon indicating copy to clipboard operation
magic-context copied to clipboard

maintain-docs fails forever when its recorded checkpoint commit is garbage-collected

Open jjjermiah opened this issue 5 days ago • 2 comments

maintain-docs failed every night for six weeks in one of my repos, in 65 ms, with no model call:

Error message="Command failed: git cat-file -t d79095917189ff8baa6d028bfa5880245e2b996b
fatal: git cat-file: could not get object info
" status=128

The checkpoint in task_schedule_state.last_checked_commit was {"head":"d79095917189…"}, recorded on 2026-10-13. That commit no longer exists in the repo. Branches there are squash-merged and deleted, so a commit the task recorded can be garbage-collected later. docsChangeSet (index-*.js, around if (anchor && (... git cat-file -t anchor !== "commit"))) throws when the anchor is missing, and nothing ever replaces the checkpoint. So the task fails until someone edits the row by hand. The dashboard shows the failure class as unknown.

Expected: an anchor that is no longer an object should fall back to the same path as no anchor (git log -1 -- ARCHITECTURE.md STRUCTURE.md), maybe with a log line, instead of failing for good.

I worked around it by setting the checkpoint to the last commit that touched the docs files. On 0.49.91.

jjjermiah avatar Nov 29 '26 15:11 jjjermiah

Confirmed in the code, and thank you for the precise report.

docsChangeSet checks a stored checkpoint with git cat-file -t <sha>. When that commit no longer exists, git exits 128, and the error is passed on because a checkpoint is stored. The run ends there, before anything can replace the checkpoint, so the task fails every night until the row is edited by hand, exactly as you saw. Squash-merged and deleted branches lead there, and so does a rebase or a force-push followed by git gc.

The fix we are building for the next 0.49 patch: a stored checkpoint that is no longer a commit in the repository is treated as no checkpoint. The run starts from the last commit that touched ARCHITECTURE.md or STRUCTURE.md, which is where a first run starts, writes one log line saying the old checkpoint was gone, and records the current head when it finishes, so the next night is a normal run again. A stored value that is not a commit id at all is handled the same way. A real git failure (the folder is no longer a repository, git cannot run) keeps today's behaviour.

Your workaround, setting the checkpoint to the last commit that touched the docs files, is the right one until then.

Two more things we are checking with it: why this failure was shown with class unknown, and whether the docs task in the upcoming 0.50 module has the same gap.

magic-alfonso[bot] avatar Nov 29 '26 15:11 magic-alfonso[bot]

Released in 0.49.95.

When the commit recorded as the docs task's checkpoint no longer exists (after a rebase, a force-push, or a squash-merged and deleted branch), the task no longer fails. It decides from git's exit status that the commit is gone, treats the run as a first run for that project, and records a new checkpoint at the end, so the next night continues normally. A failure of git for any other reason is still reported as a failure and leaves the checkpoint alone.

No manual edit of the store is needed after the update; the next scheduled run repairs itself. Update with npx @cortexkit/magic-context@latest setup and restart the host. Thank you for the precise report.

magic-alfonso[bot] avatar Dec 01 '26 19:12 magic-alfonso[bot]