Repository navigation
Conversation
A remote delta read that exits 0 yet prints nothing carries no delta. Capturing it published an empty, unclassifiable result that woke firstmate forever. Capture the read's output and report an empty window (75) when it is empty, so the source relistens instead.
[Low impact] The PR appears safe to merge and matches the stated intent. Reviews (1) · Last reviewed commit: "no-mistakes(review): Skip caught-up wate..." · Reviewed by Greptile |
Contributor
Author
|
Trillium Firstmate here 🤖 Closing as superseded:
|
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.
Intent
Contribute to upstream kunchenguid/firstmate a single fix: in bin/fm-procevent-remote-reply.sh cmd_source, a remote delta read (fm-on.sh fm-remote-delta-read.sh) that exits 0 but prints nothing carries no delta; capturing it publishes an empty, unclassifiable result that wakes firstmate forever. Capture the read's output and, when the exit is 0 and the output is empty, treat it as an empty window (WINDOW_CLOSED_EMPTY, 75) so the source relistens. Regression test in tests/fm-remote-reply.test.sh via a fake remote that exits 0 with no output. One change only, forked from upstream main, no bundling; PR is opened against kunchenguid/firstmate from the trillium fork. No AI attribution or co-author trailers. Never merge.
What Changed
cmd_sourceinbin/fm-procevent-remote-reply.shnow captures the output of thefm-remote-delta-read.shread to a temp file. If the read exits 0 and printed nothing, it treats the result as an empty window and returns the preempted code, so the source relistens. Otherwise it passes the output through unchanged. Previously this case published an empty, unclassifiable result that woke firstmate repeatedly.tests/fm-remote-reply.test.shadds a regression test that uses a fake remote exiting 0 with no output.Risk Assessment
✅ Low: This is a small, bounded change to cmd_source: an exit-0 read with empty output now returns 75 without writing a watermark, as the user instructed, and every other exit code and non-empty output passes through as before.
Testing
I ran the changed regression test file; it passed, including the new exit-0 empty-read case. I then drove the real source CLI and the real process-event runner, on the change and on the base-commit adapter, with a fake ssh transport. On the base commit, an exit-0 empty read returned 0, so the runner published an empty 0-byte result and stopped listening with 1 pending. With the change, it returned 75 with no output and no watermark, and the runner stayed live. That run made 7 relisten reads and published 0 results. With the change, a genuine quiet window still returned 75 and recorded the caught-up watermark, and a real reply line still came through as an intact delta with rc 0. I ran the base-commit comparison only for the exit-0 empty case and the runner. Its other two cases failed on a temp-path setup check, so the evidence for those comes from the change side only. There is no UI surface. All temp copies were removed and the worktree is clean. The regression test file run is a unit test, not a live product drive, so it is recorded as untested for live purposes.
Evidence: source CLI transcript (after vs before)
Source: source CLI transcript (after vs before)
AFTER: S1 exit-0 empty -> rc=75 stdout_bytes=0 watermark=[] | S2 genuine quiet -> rc=75 watermark=[1793059107] | S3 reply line -> rc=0 status=delta payload_bytes=46 ... BEFORE: S1 exit-0 empty -> rc=0 stdout_bytes=0 (S2/S3 hit a temp-path setup check in the base copy and were not compared)Evidence: process-event runner transcript (after vs before)
Source: process-event runner transcript (after vs before)
AFTER: owner=live pending=0, remote reads in 8s: 7, published results: 0 BEFORE: owner=none pending=1, remote reads in 8s: 1, published results: 1 (remote-reply-ios.1.result bytes=0)Evidence: regression test file log
Source: regression test file log
ok - an exit-0 empty remote read is an empty window, not a captured result ... ALL TESTS PASSEDPipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 2 issues found → auto-fixed ✅
bin/fm-procevent-remote-reply.sh:319- The new code rewrites an exit-0 empty read to rc=$WINDOW_CLOSED_EMPTY before the existing branch runs, so it also calls fm_pending_reply_note_remote_channel_caught_up and records a caught-up watermark atstarted. An exit-0 empty read is an anomaly: the real fm-remote-delta-read.sh exits 75 itself when a window closes empty, so this output usually means the read never really ran (for example, a transport glitch in fm-on.sh). That proves nothing about the channel being caught up, which is the same reason JOB_PREEMPTED deliberately skips the watermark. Failure path: a correlated report is sitting unread in the remote log, fm-on.sh returns 0 with no output, and the watermark is written with epoch >= since. The reply guard in fm-pending-reply-lib.sh:945 then treats the channel as caught up and can send a premature 'REPOST REQUIRED' recovery for a report that actually exists. Smallest remedy: send this case down the JOB_PREEMPTED-style path (return 75, record no watermark). It still meets the intent's 'empty window (75), relisten' requirement. Asking because the intent's wording 'treat it as an empty window' could be read to include the watermark.bin/fm-procevent-remote-reply.sh:317- The new mktemp capture file is removed only on the normal path. If the source is terminated while it blocks in the long-poll, the file stays in TMPDIR. The files are small and empty or bounded, and the impact is minor.🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
bash tests/fm-remote-reply.test.sh(whole file, includes the new 'an exit-0 empty remote read is an empty window, not a captured result' case): ALL TESTS PASSEDManual driver: called the realfm-procevent-remote-reply.sh source iosthrough the real fm-on.sh / fm-remote-entrypoint.sh / fm-remote-delta-read.sh path with a fake ssh transport. Ran 3 cases (exit-0 empty, genuine quiet window, real reply line) on the change and on the base-commit adapterManual driver:fm-procevent-remote-reply.sh arm ios+fm-procevent.sh start remote-reply-iosfor 8s with an ssh transport that always exits 0 with no output, thenfm-procevent.sh listand a count of published .result files; ran on the change and on the base-commit adapter✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.