fix(mag): briefing queues /compact after feedback-digest (task-304a02a6)#494
fix(mag): briefing queues /compact after feedback-digest (task-304a02a6)#494
Conversation
Swap order in magBriefing() so the on-disk queue becomes briefing → feedback-digest → /compact. /compact had been wiping the briefing context before feedback-digest could read it; now /compact lands last so digest sees prior context and the next session starts fresh. Comment block above /compact rewritten to drop the now-false "directly behind" rationale; task-a00fc0d9 reference preserved. Test renamed to assert the new invariant (last item is /compact, middle item is feedback-digest in clean state) and a sibling test covers the gated branch (length 2 with /compact still last). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ebb56301fb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // Auto-queue feedback-digest once daily alongside the briefing trigger. | ||
| // Lands before /compact so digest can consume the briefing's in-flight | ||
| // context (task-304a02a6 / docs/proposals/task-304a02a6-reorder-briefing-auto-queue.md). | ||
| const fdResult = tryQueueFeedbackDigest("ludics"); |
There was a problem hiding this comment.
Guard /compact enqueue from feedback-digest failures
magBriefing now calls tryQueueFeedbackDigest("ludics") before queuing /compact, but that helper can throw (for example, queue lock timeout in queueRequest or state-file write failures in markFeedbackDigestQueued). In those cases the function exits before enqueuing /compact, which breaks the stated “always compact after briefing” contract and can leave the next session with stale context. The /compact enqueue should be made failure-safe (e.g., via try/finally) so digest errors do not suppress compaction.
Useful? React with 👍 / 👎.
…review)
Wrap the tryQueueFeedbackDigest("ludics") call in magBriefing() with
try/catch so a queue-lock timeout or state-file write failure inside
the digest path can no longer suppress the unconditional /compact
enqueue. The auto-compact-after-checkpoints contract (task-a00fc0d9)
requires /compact after every briefing; the round-1 swap exposed that
contract to digest-side failures because /compact moved below the
digest call.
Add a regression test that spies on queueRequest to throw on the
feedback-digest action and asserts (a) /compact still lands in
mag/queue.jsonl as the second entry, and (b) the failure is logged.
Mutation-verified: removing the try/catch makes the new test fail.
Addresses Codex review comment on src/mag.ts:3320.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
note: branch state has drifted since this body was written (baseline: 1 commit at 2026-05-04T05:23:01Z, current: 2 commits). consider |
Summary
magBriefing()(src/mag.ts) so the on-disk queue becomesbriefing → feedback-digest → /compact./compacthad been wiping the briefing's in-flight context beforefeedback-digestcould read it; now/compactlands last so digest sees the prior context and the next session starts fresh./compactenqueue: drops the now-false "directly behind" / "before any later automated enqueues" rationale, names the actual reason ("LAST follow-up so the next session starts fresh"), and keeps the task-a00fc0d9 /auto-compact-after-checkpoints.mdreference (auto-compact contract is unchanged).src/mag-auto-compact.test.tsto assert the new invariant (/compactis the final queue item,feedback-digestsits betweenbriefingand/compactwhen ungated). Add a sibling negative-control test that pre-seeds a pendingfeedback-digestto exercise the gated branch and confirm/compactstill lands last (queue length 2).tryQueueFeedbackDigest("ludics")call intry/catchso a queue-lock timeout or state-file write failure in the digest path cannot suppress the unconditional/compactenqueue (the auto-compact-after-checkpoints contract requires/compactafter every briefing). Add a regression test that spies onqueueRequestto throw on thefeedback-digestaction and asserts/compactstill lands; mutation-verified by removing the try/catch.magHealthCheck's/compactenqueue (src/mag.ts:3485) is untouched — it has no co-queued digest, so the ordering bug doesn't apply there.Proposal:
docs/proposals/task-304a02a6-reorder-briefing-auto-queue.mdTest plan
bun run typecheckbun run lintbun run buildbun test src/mag-auto-compact.test.ts— 8/8 pass (covers ungated 3-item ordering, gated 2-item ordering, digest-throws-still-enqueues-/compact, and the unchanged health-check path)🤖 Generated with Claude Code