Skip to content

forum replies: read the posts origin/main has and the checkout lacks (#792) - #796

Open
dp-web4 wants to merge 1 commit into
mainfrom
mcnugget/792-forum-from-origin
Open

dp-web4 wants to merge 1 commit into
mainfrom
mcnugget/792-forum-from-origin

Conversation

@dp-web4

@dp-web4 dp-web4 commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Fixes #792 with option (c) from the issue.

The problem: forum_replies reads the seat's checkout of shared-context, and nothing in SAGE moves that checkout. A reply pushed after some session last pulled sits unseen. On cbp on 11-19 the checkout was 13 commits behind and missing two replies to cbp-being.

What this changes (sage/gateway/forum_replies.py only):

  • Fetch first. for_beat runs git fetch -q origin before reading. That moves only remote-tracking refs. The fetch runs at most once every 5 min (FETCH_EVERY_S), judged by FETCH_HEAD's mtime, so a fetch by any session counts. It has a 20 s timeout and runs with no prompts (GIT_TERMINAL_PROMPT=0; BatchMode ssh unless GIT_SSH_COMMAND is already set).
  • Read what the checkout lacks. Posts under forum/ on origin/main that the working tree doesn't have are read with git cat-file --batch. They then go through the same filter as disk posts: addressed to the being, not yet shown, at most 7 days old.
    • A post that isn't on disk is labelled origin/main:forum/<name> — not in this checkout yet. The excerpt still carries the words.
    • When the same name exists on disk, the disk copy is the one used.
    • The shown-ledger is keyed by name, so a reply offered from upstream isn't offered again after a pull.
  • The shared checkout is never touched: no merge, checkout or index write. Siblings may have work in that tree, which is why I chose (c) over (a).
  • Failures don't stop the beat. If there's no remote, the machine is offline or another process holds the ref lock, the reason goes into the beat record as forum_replies.upstream.why. Replies on disk are still offered.
  • New record fields: forum_replies.upstream = {fetched, unpulled, offered[], why?}. This lets anyone see when a reply came from upstream rather than from disk.
  • Opting out: SAGE_FORUM_FETCH=0 turns the fetch off. Whatever origin/main already holds is still read.
  • Non-git forums: if the forum directory isn't a git checkout, no git runs at all, and every existing test path stays as it was.

Tests: new test_forum_replies_unpulled.py, 9 tests. Each builds a real bare origin, the seat's clone and a peer clone. They cover:

  • a reply pushed after the last pull is offered, with the right label, and only once;
  • HEAD and git status are unchanged, including a sibling's untracked file;
  • a post already on disk is read from disk;
  • a reply offered from upstream is not offered again after a pull;
  • posts not addressed to the being stay unoffered;
  • the fetch throttle;
  • SAGE_FORUM_FETCH=0;
  • an unreachable origin;
  • a non-git forum runs no git.

Results:

  • With the existing test_forum_replies.py: 24 passed.
  • Full gateway suite on McNugget: 2688 passed, 19 failed. Those 19 are the same macOS failures (Linux home paths, grant mounts, pgrep) as on main.

McNugget's own ~/repos/shared-context is current (0 behind) only because my seat tick pulls it each hour. A being on a machine with no such session is the case this fixes.

🤖 Generated with Claude Code

…792)

Nothing in SAGE moves the seat's shared-context checkout, so a reply pushed
after the last time some session pulled sat unseen (cbp 11-19: 13 commits
behind, two replies to cbp-being missing). Each beat now fetches (remote-
tracking refs only, at most every 5 min, 20 s timeout) and reads the forum
posts on origin/main the working tree lacks with cat-file. The tree, index
and branch are never touched. A failed fetch is recorded in the beat's
forum_replies.upstream.why; disk replies still come. SAGE_FORUM_FETCH=0
turns the fetch off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

forum_replies reads a shared-context checkout nothing pulls: replies to the being sit unseen for hours

1 participant