Skip to content

fix: preserve complete steering inbox messages - #6095

Open
jcpoyser wants to merge 4 commits into
kunchenguid:mainfrom
jcpoyser:fm/fm-inbox-final-newline-r2
Open

jcpoyser wants to merge 4 commits into
kunchenguid:mainfrom
jcpoyser:fm/fm-inbox-final-newline-r2

Conversation

@jcpoyser

@jcpoyser jcpoyser commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Intent

Diagnose and fix steering messages that a worker can miss because the message file has no final newline.

Context: a worker reportedly dropped single-line steering-inbox messages because its read loop ignored an unterminated final line, and a handled marker alone did not prove the content was read. This was not independently reproduced. The fix was approved on 2026-09-28 as: diagnose first, then fix with tests.

Bring this branch up to date with current main without force (merge, not rebase-and-force-push). Add the small check that stops safely when a message body is shorter than its recorded byte length (the Greptile P2 note), with a regression test. Validate through no-mistakes as before, keep the PR description and attestation intact (edit with gh pr edit --body-file only), and report when the PR is green again. This covers follow-up item fm-inbox-truncation-check.

What Changed

  • Record exact message body byte lengths and terminate newly written records with a newline, so line readers can see single-line messages that lacked a final newline.
  • Read recorded bodies by byte length and reject truncated bodies without emitting partial content, while keeping legacy records readable.
  • Update worker inbox instructions to require reading the complete message and add regression coverage for unterminated and truncated messages.

Risk Assessment

✅ Low: The change is limited to inbox record length tracking, safe body reads, and focused regression coverage; no material source defect was found.

Testing

The inbox tests completed successfully. The combined targeted-test command timed out while running the brief tests; rerunning that script separately completed successfully. Manual isolated checks confirmed the complete unterminated message was returned and a truncated body failed without partial output. No reviewer-visible file artifacts were produced.

  • Live validation: ✅ go - 2 of 2 scenarios driven live against the product
Scenario Result Live Evidence
A worker reads a single-line steering message without a final newline and receives the complete text ✅ pass live Manual isolated fm_task_inbox_write and fm_task_inbox_body execution; output shown in “Isolated inbox read behavior”.
A truncated inbox record is refused without exposing partial message content ✅ pass live Manual isolated fm_task_inbox_body execution on a truncated record; exit status 1 and zero output bytes shown in “Isolated inbox read behavior”.
Evidence: Isolated inbox read behavior
single-line steering without newline
truncated_read_exit=1 partial_output_bytes=0

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 2 of 2 scenarios driven live against the product
Scenario Result Live Evidence
A worker reads a single-line steering message without a final newline and receives the complete text ✅ pass live Manual isolated fm_task_inbox_write and fm_task_inbox_body execution; output shown in “Isolated inbox read behavior”.
A truncated inbox record is refused without exposing partial message content ✅ pass live Manual isolated fm_task_inbox_body execution on a truncated record; exit status 1 and zero output bytes shown in “Isolated inbox read behavior”.
  • bash tests/fm-task-inbox.test.sh
  • bash tests/fm-brief.test.sh (rerun separately after the combined invocation timed out)
  • Manually wrote and read a no-final-newline message through fm_task_inbox_write and fm_task_inbox_body, then attempted to read a truncated record.
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@greptile-apps

greptile-apps Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Fixes message file reading to preserve unterminated final lines.

The PR appears safe to merge based on the reviewed changes.

Reviews (2) · Last reviewed commit: "Reject truncated steering inbox payloads"

Comment thread bin/fm-task-inbox-lib.sh Resolved
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: First stamp this fetch vs tip c5f48e4cad279e6acaf14208522c44e28fac6835 (base on PR is 40e981da; tip diverged — ahead 2 / behind 2 vs pre-merge main, and main moved again with #6110).

HEAD 6f0220ce0d474b769ba3d1175fd7080aa91da674. MERGEABLE/UNSTABLE. Closes #6091 verified (steering inbox records / complete message body). Attestation MATCH (live_validation go 2/2). Latest NM body-compliance SUCCESS (36535799672; earlier edit-event failure 36527141536 superseded). Behavior 36526178279 SUCCESS. Greptile Review FAILURE (P2: truncated record after body-bytes header can make head -c look successful — author notes truncated-message check as follow-up outside this change).

Tip vs main (own diff): writers emit body-bytes= + terminating record newline while preserving exact payload bytes; fm_task_inbox_body reads by byte count (legacy records without metadata still cat after --); brief text requires complete contents / warns against line loops that drop an unterminated final line; regressions for unterminated + legacy.

Contract-class: restore — durable steering-inbox delivery already promised exact message bodies to workers; missing record terminator + line-loop drops broke that concrete path. body-bytes + trailing newline restore exact round-trip; legacy read kept. Brief wording clarifies the existing inbox contract (not a new captain-facing observer). FM-LEARN-4627: not always-on Bearings/wake.

VISION.md per-rule

  1. One captain, one interface — aligns (steering reaches the worker complete).
  2. Authority explicit — aligns (no consent widen).
  3. Scripts own mechanics — aligns (byte-exact inbox lib).
  4. Restart non-event — aligns (durable inbox records survive).
  5. Delegation with a spine — aligns (steer contract honesty).
  6. Fleet outlives vendor — aligns (harness-agnostic inbox files).
  7. Scope — aligns (inbox lib + brief + tests).

Security: bin/tests only. Clean.
Decision: waiting-author — please rebase onto current main (c5f48e4cad279e6acaf14208522c44e28fac6835) and either fail-closed on short body-bytes reads (Greptile P2) or keep UNSTABLE acknowledged; not auto-merge while diverged/UNSTABLE. Firstmate flag no.

@jcpoyser

Copy link
Copy Markdown
Contributor Author

Behavior portable serial 8 and Behavior portable serial 9 failed: remote seed did not provision the route. This PR touches only bin/fm-brief.sh, bin/fm-task-inbox-lib.sh, and their tests. GitHub requires repository admin rights to rerun these jobs; could a maintainer rerun both? @jcpoyser

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.

2 participants