Skip to content

docs: make the Herdr backend guide easier to read - #5606

Merged
kunchenguid merged 2 commits into
kunchenguid:mainfrom
tmchow:docs/herdr-backend-readable
Sep 25, 2026
Merged

kunchenguid merged 2 commits into
kunchenguid:mainfrom
tmchow:docs/herdr-backend-readable

Conversation

@tmchow

@tmchow tmchow commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Intent

Improve the kunchenguid/firstmate documentation. Many of the docs are hard to read because they were clearly agent-written. That is not necessarily bad, but some docs are almost impossible for a human to understand.
Give docs/herdr-backend.md a ce-noslop rewrite that still communicates the same information but improves readability, the way PR #5589 did for docs/configuration.md.
That PR turned long prose paragraphs into task navigation, tables, bullet lists, numbered procedures, and shorter ### subsections. It kept every original heading and anchor, left every fenced code block byte-identical, and preserved every documented fact, default, qualifier, safety limit, identifier, quoted string, and link target, with one sentence per line.
This is a documentation-only change with no runtime behavior impact.

What Changed

  • Rewrote docs/herdr-backend.md for readability. Long prose paragraphs are now tables, bullet lists, numbered procedures, and shorter ### subsections covering spawn preflight, placement, the presentation journal, cleanup, composer proof, submit confirmation, the polling fallback, and the daemon. The text is one sentence per line.
  • Added a "Find a topic" navigation table at the top. Every original heading and anchor is kept, and no fenced code block was edited.
  • The rewrite keeps the facts, defaults, safety limits, identifiers, and link targets from the original, including the reason given for Claude composer proof. The change touches documentation only and doesn't change runtime behavior.

Risk Assessment

✅ Low: This change only touches documentation. Every original heading, anchor, link target, backticked identifier, number, and fenced code block is preserved, and all headings still have unique anchors. The only gaps are an incomplete navigation table and one dropped causal link.

Testing

This is a documentation-only change to docs/herdr-backend.md with no runtime surface, so I did not start a Herdr lab or any product. Structural checks against the base commit passed. Both fenced code blocks are byte-identical and in the same order. All 15 original headings and their anchors are still present, and no link target was dropped. The newly added in-doc navigation links, the relative file links, and all 6 inbound cross-doc anchor references resolve. No non-list prose line holds more than one sentence. I made no visual capture because the change is Markdown source with no rendered app UI. Checking that every documented fact survived is a job for review, not live testing.

  • Live validation: ⚠️ no-surface - 0 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Herdr backend runtime behavior is unchanged by the doc rewrite ⏸️ untested no No live surface to validate: the change touches only a Markdown doc and no code, script, or config. No Herdr lab scenario (bin/fm-herdr-lab.sh) would exercise it.
A reader following an existing cross-doc link into docs/herdr-backend.md#<anchor> lands on the same section ⏸️ untested no No live surface to validate: this is a static check of Markdown anchors, not a run of the product. It passed statically.
Every fenced code block, original heading, and link target is preserved ⏸️ untested no No live surface to validate: this is a doc-only structural comparison with no product to run. It passed statically.
Evidence: Structure preservation check output

Source: Structure preservation check output

code blocks before/after: 2 2
code blocks missing/altered: 0
code blocks sequence identical: True
headings before/after: 15 57
original headings missing: []
anchors lost: []
html anchors lost: []
link targets dropped: []
link targets added: ['#active-limits', '#client-selection', '#composer-and-injection-safety', '#current-transport-behavior', '#destructive-lab-safety', '#endpoint-metadata', '#regression-entry-points', '#restart-and-liveness-behavior', '#setup', '#watching-and-task-containers']
unresolved in-doc anchors: []
unresolved relative file links: []
inbound anchor refs: 6 unresolved: []
lines possibly holding >1 sentence: 29
  > 1. Reads `status --json --session <name>` from each distinct `herdr` on `PATH`, in order.
  > 2. Adopts the first one the running server reports compatible.
  > 3. Retries the command on it once.
  > 1. Firstmate atomically publishes a three-field version 1 journal containing a random 128-bit base64url token, before asking Herdr to create anything.
  > 2. After the new workspace converges to one exact task endpoint beneath one exact parent workspace id, the journal advances to a version 2 binding.
  > 1. Verify the close would empty the workspace.
  > 2. When needed, reposition the doomed workspace behind the focused one through the verified `workspace.move` transport.
  > 3. Prove the pane holds one lone idle shell.
  > 4. End that shell, so Herdr removes the emptied workspace through its focus-preserving pane-death path.
  > 1. Acquire the existing task-id spawn lock, and then the shared named-session presentation lock.
non-list lines possibly holding >1 sentence: 0
Evidence: Structure check script

Source: Structure check script

import re,sys,subprocess,os,collections
b=open(sys.argv[1]).read(); a=open(sys.argv[2]).read()
def blocks(t):
    out=[];cur=None;fence=None
    for l in t.split('\n'):
        m=re.match(r'^(\s*)(`` `+|~~~+)',l)
        if cur is None and m: cur=[l];fence=m.group(2);continue
        if cur is not None:
            cur.append(l)
            if l.strip().startswith(fence) and l.strip().strip(fence[0])=='' : out.append('\n'.join(cur));cur=None
    return out
def strip(t):
    return re.sub(r'(?ms)^\s*(`` `+|~~~+).*?^\s*\1\s*$','',t)
def heads(t): return [l for l in strip(t).split('\n') if re.match(r'^#{1,6} ',l)]
def slug(h):
    s=re.sub(r'^#+ ','',h).strip().lower(); s=re.sub(r'[^\w\- ]','',s); return s.replace(' ','-')
def links(t): return collections.Counter(re.findall(r'\]\(([^)\s]+)',strip(t)))
def html_anchors(t): return set(re.findall(r'<a (?:name|id)="([^"]+)"',t))
bb,ab=blocks(b),blocks(a)
print("code blocks before/after:",len(bb),len(ab))
missing=[x for x in bb if x not in ab]; print("code blocks missing/altered:",len(missing))
print("code blocks sequence identical:", bb==ab)
hb,ha=heads(b),heads(a)
lost=[h for h in hb if h not in ha]; print("headings before/after:",len(hb),len(ha)); print("original headings missing:",lost)
sb=set(map(slug,hb)); sa=set(map(slug,ha)); print("anchors lost:",sorted(sb-sa)); print("html anchors lost:",sorted(html_anchors(b)-html_anchors(a)))
lb,la=links(b),links(a); print("link targets dropped:",sorted(set(lb)-set(la))); print("link targets added:",sorted(set(la)-set(lb)))
# internal anchors in after resolve
bad=[l for l in la if l.startswith('#') and l[1:] not in sa|html_anchors(a)]; print("unresolved in-doc anchors:",bad)
# relative file links resolve
d=os.path.dirname(sys.argv[3])
badf=[l for l in la if not l.startswith(('#','http')) and not os.path.exists(os.path.normpath(os.path.join(d,l.split('#')[0])))]; print("unresolved relative file links:",badf)
# inbound references
r=subprocess.run(['git','grep','-hoE',r'herdr-backend\.md#[A-Za-z0-9_-]+'],capture_output=True,text=True).stdout.split()
inb=sorted(set(x.split('#')[1] for x in r)); badin=[x for x in inb if x not in sa|html_anchors(a)]
print("inbound anchor refs:",len(inb),"unresolved:",badin)
# one sentence per line (outside code/tables): lines with >1 sentence end
multi=[l for l in strip(a).split('\n') if not l.startswith('|') and len(re.findall(r'[a-z0-9`)\]]\. [A-Z`]',l))>0]
print("lines possibly holding >1 sentence:",len(multi))
for l in multi[:10]: print("  >",l[:160])
- Outcome: ⚠️ 1 warning across 1 run (40.8s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 2 infos
  • ℹ️ docs/herdr-backend.md:14 - The new 'Find a topic' table (docs/herdr-backend.md:14-26) reads as an index of the page, but three ## sections are missing from it: 'Default-tab prune safety' (line 481), 'Push events and polling fallback' (line 718), and 'Away-mode supervisor support' (line 748). A reader looking for push events or the away daemon will not find them in the table. Add a row for each, for example 'Why a seeded default tab is or is not closed', 'How blocked transitions arrive and what happens without protocol 16', and 'Where the away daemon runs and how it stops'.
  • ℹ️ docs/herdr-backend.md:556 - The rewrite splits the original sentence 'Other harnesses, and panes with no native identity, skip this proof and keep the type-then-Enter path, because their paste placeholders and composer shapes are not live-verified.' into two sentences at lines 555-556. The split drops the stated cause: the old text said these panes skip the proof because their shapes are unverified, and the new text only puts the two facts next to each other. The intent requires preserving every qualifier. Restore the causal link, for example 'They skip it because their paste placeholders and composer shapes are not live-verified.'
⚠️ **Test** - 1 warning
  • ⚠️ this change has no live-validatable surface; proceed without live validation? (0 of 3 scenarios were driven live against the product); Herdr backend runtime behavior is unchanged by the doc rewrite: No live surface to validate: the change touches only a Markdown doc and no code, script, or config. No Herdr lab scenario (bin/fm-herdr-lab.sh) would exercise it.; A reader following an existing cross-doc link into docs/herdr-backend.md#<anchor> lands on the same section: No live surface to validate: this is a static check of Markdown anchors, not a run of the product. It passed statically.; Every fenced code block, original heading, and link target is preserved: No live surface to validate: this is a doc-only structural comparison with no product to run. It passed statically.
  • Live validation: ⚠️ no-surface - 0 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Herdr backend runtime behavior is unchanged by the doc rewrite ⏸️ untested no No live surface to validate: the change touches only a Markdown doc and no code, script, or config. No Herdr lab scenario (bin/fm-herdr-lab.sh) would exercise it.
A reader following an existing cross-doc link into docs/herdr-backend.md#<anchor> lands on the same section ⏸️ untested no No live surface to validate: this is a static check of Markdown anchors, not a run of the product. It passed statically.
Every fenced code block, original heading, and link target is preserved ⏸️ untested no No live surface to validate: this is a doc-only structural comparison with no product to run. It passed statically.
  • git diff --stat b42d4fa 138721e (confirmed only docs/herdr-backend.md changed)
  • python3 check.py before.md after.md docs/herdr-backend.md: compared the fenced code block sequence byte-for-byte, checked the original headings and slug anchors, compared link-target sets, resolved in-doc anchors and relative file links, and resolved inbound herdr-backend.md#... references across the repo via git grep
  • Scan for one sentence per line on the rewritten doc, skipping code blocks, tables, and list markers
🔧 **Document** - 1 issue found → auto-fixed ✅
  • ℹ️ tests/fm-backend-herdr.test.sh:3989 - Several test comments name docs/herdr-backend.md sections that are not headings or text in the doc. The names are "Known gaps", "ID stability across a server restart", "Task container shape", "Incident (2026-07-07)", "Native agent-state submit confirmation" and "Busy state". Affected files: tests/fm-backend-herdr.test.sh, fm-backend-herdr-smoke, fm-backend-herdr-respawn-idem-e2e, fm-afk-inject-herdr-e2e, fm-crew-state and fm-backend.test.sh. These names were already missing before this change, so this rewrite did not cause them. Fixing them means editing test files, which is outside this docs-only change. A later follow-up could repoint these comments to the current anchors, such as #default-tab-prune and #restart-and-liveness-behavior.

🔧 Fix applied.
✅ Re-checked - no issues remain.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Restructure the Herdr backend doc's prose into shorter sections, lists, numbered procedures, and tables without changing documented behavior. Every original heading, anchor, fenced code block, link target, and documented fact is kept.
@kunchenguid
kunchenguid merged commit 660fa4a into kunchenguid:main Sep 25, 2026
19 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: this is merged. Thank you @tmchow — really appreciate you taking the time on this.

mituso89 pushed a commit to mituso89/firstmate that referenced this pull request Sep 26, 2026
* docs: make herdr-backend easier to read

Restructure the Herdr backend doc's prose into shorter sections, lists, numbered procedures, and tables without changing documented behavior. Every original heading, anchor, fenced code block, link target, and documented fact is kept.

* no-mistakes(document): Restore composer-proof reason and complete Herdr topic table
mehulbhagwani pushed a commit to mehulbhagwani/firstmate that referenced this pull request Sep 26, 2026
* docs: make herdr-backend easier to read

Restructure the Herdr backend doc's prose into shorter sections, lists, numbered procedures, and tables without changing documented behavior. Every original heading, anchor, fenced code block, link target, and documented fact is kept.

* no-mistakes(document): Restore composer-proof reason and complete Herdr topic table
mehulbhagwani pushed a commit to mehulbhagwani/firstmate that referenced this pull request Sep 26, 2026
* docs: make herdr-backend easier to read

Restructure the Herdr backend doc's prose into shorter sections, lists, numbered procedures, and tables without changing documented behavior. Every original heading, anchor, fenced code block, link target, and documented fact is kept.

* no-mistakes(document): Restore composer-proof reason and complete Herdr topic table
ashkonmousavi added a commit to ashkonmousavi/firstmate that referenced this pull request Sep 26, 2026