Skip to content

feat(backends): add experimental explicit-only tern runtime backend - #7536

Merged
kunchenguid merged 10 commits into
kunchenguid:mainfrom
chsong1:tern-backend
Oct 25, 2026
Merged

kunchenguid merged 10 commits into
kunchenguid:mainfrom
chsong1:tern-backend

Conversation

@chsong1

@chsong1 chsong1 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Intent

Update existing upstream PR #7536 to the maintainer's offered auto-merge path. Rebase the experimental Stencil Tern backend onto upstream main preserving Paseo integration. Make Tern explicit-only: only --backend tern, FM_BACKEND=tern, or config/backend select it; ambient TERM_PROGRAM=tern and TERN_PANE must not change the default. Update affected docs and behavior tests, retain existing backend safety, and remove the unrelated timeout library change and its test from this PR. The caller ships that timeout fix separately from fix/timeout-type-p; do not create its companion in this run. Supervisor explicitly superseded old run 01M5BHMM9VHBQ6M020PSPZ5W22 and authorized abort, guarded archive-backed custody recovery, rebuilding without obsolete-run fix commits, then exact-SHA archival and retirement of only the stale private mirror ref. Those steps are complete; archive refs remain preserved. Validate this revised head and let the pipeline push to chsong1/firstmate branch tern-backend, update existing upstream PR #7536 with a fresh head-bound attestation, and verify CI. No direct push outside the pipeline, no merge, no additional PRs or upstream comments. The caller posts exactly one review reply after both PRs exist. Local evidence: lint, docs, invariants and backend smoke pass; six focused backend/bootstrap/control/safety scripts pass, but the runner's nested session-lock fixture fails. Broad portable run had host/fixture failures and a one-hour timeout, not a clean pass; evaluate required targeted behavior honestly.

What Changed

  • Adds bin/backends/tern.sh, an experimental Stencil Tern backend you can spawn tasks on. Each home gets one Tern session named fm-<hometag>, and each task is a renamed keep-open tab. Metadata is validated as window=<session-id>:<block-id> plus tern_session_id, tern_tab_id and tern_block_id, where every id is a decimal u64. The backend also supports visible-viewport capture with tern capture --surfaces, sending keys and text, and reading native agent state through tern ctl; when that read is unavailable, state degrades instead of failing. Closing an endpoint is refused if the block is still present, the inventory can't be read, or the task tab was renamed.
  • Wires tern into the shared backend layer and its callers: the known/spawn lists, required tools (tern jq treehouse), and the spawn, control, busy-state, composer, supervise-daemon, bootstrap, AFK-launch and test-runner paths. Tern can only be selected explicitly, through --backend tern, FM_BACKEND=tern or config/backend. fm_backend_detect ignores the inherited TERM_PROGRAM=tern and TERN_PANE markers, so a tmux or Herdr session started inside a Tern block keeps its normal default.
  • Adds docs/tern-backend.md and updates the README, architecture, configuration, scripts and runtime-backend verification docs, plus the harness and skill references. Adds tern unit and smoke tests (tests/fm-backend-tern*.test.sh) and a tests/tern-test-safety.sh guard that refuses to close a session hosting the caller's own block. Extends the existing backend, bootstrap, busy-state, control, daemon, teardown-safety and test-run tests to cover tern.

🤖 Generated with Claude Code

Risk Assessment

✅ Low: The Tern backend is experimental, explicit-only and well fenced: tests cover that fm_backend_detect ignores TERM_PROGRAM=tern and TERN_PANE, stop and relaunch verbs still refuse tern, kill refuses on an unreadable inventory, a moved block, a renamed tab, or a block that survives its close, and capture JSON normalization and the narrowed Carly projection are correctly implemented and tested. The timeout library and its test are unchanged from base, and the Paseo integration is intact.

Testing

Backend selection was driven against the real fm-backend dispatcher. Ambient TERM_PROGRAM=tern/TERN_PANE fall back to tmux; only FM_BACKEND=tern or config/backend selects tern. The Tern adapter was driven against the real tern 0.9.4 daemon in a disposable, guarded fm-test- session, which was removed afterwards; the user's Default and primary sessions were not touched. Capture returns screen text and target labels are verified. A hand-renamed task tab makes kill refuse and leaves the block open; once the title is restored, kill closes it and a repeat kill does nothing. The repo's real-Tern smoke test skips on this host because tern ctl state has no window endpoint, so live native agent state could not be proven (it reads unknown). The JSON .text capture normalization was covered only by the fake-CLI behaviour suite, because this host's tern returned plain text. The timeout-exclusion and Paseo checks are a diff check plus a behaviour suite, not live runs. The focused tern, backend, teardown-safety and Paseo suites all pass. No artifacts were left in the worktree.

  • Live validation: ✅ go - 4 of 7 scenarios driven live against the product
Scenario Result Live Evidence
Ambient TERM_PROGRAM=tern and TERN_PANE with no explicit choice keep the default backend (tmux), including when nested in tmux ✅ pass live tern-selection.txt: selected=tmux in both ambient cases
FM_BACKEND=tern or config/backend=tern selects tern and passes spawn validation; config/backend=tmux beats ambient Tern markers ✅ pass live tern-selection.txt; fm-backend.log ('tern is never auto-detected ... only FM_BACKEND or config/backend select it')
Tern adapter against the real tern daemon: create a task block in its own fm-test- session, verify it by label, send a line, capture readable screen text ✅ pass live tern-live-adapter.txt
Adversarial: hand-renaming a task's tab makes kill refuse (nonzero) and leaves the block open; after the title is restored, kill closes it and a repeat kill succeeds ✅ pass live tern-live-adapter.txt ('kill refused renamed block (rc=1)', 'renamed block ... still open')
Capture output that is a JSON {block,text} envelope is reduced to .text before the line trim ⏸️ untested no The prior payload did not establish a live result. The real tern 0.9.4 on this host returned plain text from tern capture --surfaces, so the JSON branch was only exercised through the fake-CLI behav…
Native agent state through the Tern window control endpoint (Carly lua projection of pane/state/alive) ⏸️ untested no tern ctl state fails (/tmp/tern.sock connection refused): no Tern window or tern serve control endpoint runs on this headless host, and starting a GUI window is out of reach here. Live native stat…
Timeout library change is excluded and Paseo integration is preserved ⏸️ untested no The prior payload did not establish a live result. This was a diff-composition check (no timeout files in git diff) plus the Paseo behaviour suite (48 ok). Paseo has no locally runnable app on this ho…
Evidence: Backend selection transcript (explicit-only Tern)

Source: Backend selection transcript (explicit-only Tern)

## ambient Tern markers only (no explicit selection)
$ TERM_PROGRAM=tern TERN_PANE=7
selected=tmux
spawn-valid
## ambient Tern markers inside tmux
$ TERM_PROGRAM=tern TERN_PANE=7 TMUX=/tmp/x,1,0
selected=tmux
spawn-valid
## FM_BACKEND=tern
$ FM_BACKEND=tern
selected=tern
spawn-valid
## config/backend = tern
$ TERM_PROGRAM=xterm
selected=tern
spawn-valid
## config/backend tmux beats ambient tern markers
$ TERM_PROGRAM=tern TERN_PANE=7
selected=tmux
spawn-valid
Evidence: Live real-tern adapter transcript (capture, rename refusal, kill, cleanup)

Source: Live real-tern adapter transcript (capture, rename refusal, kill, cleanup)

ok - container_ensure -> session 7868380086273 (fm-test-gate-2411173)
create_task -> tab=7885559955457 block=7885559955458; tab title: null
fm-firstmate-c4eb0a18-test-g1
ok - target_exists with label
ok - mismatched label refused
--- raw 'tern capture --surfaces' output (first 200 bytes):
user@calserver:/tmp$ echo composed-line-tern
composed-line-tern
user@calserver:/tmp$

--- fm_backend_tern_capture 5 lines:
user@calserver:/tmp$ echo composed-line-tern
composed-line-tern
user@calserver:/tmp$
ok - capture normalized to screen text (not JSON)
ok - visible_capture shows line
composer_state=unknown agent_state=dead busy_state=unknown native=unknown
tab title after rename: null
hand-renamed
error: tern block 7885559955458 in session 7868380086273 is no longer in a tab titled fm-firstmate-c4eb0a18-test-g1, so it cannot be verified as this task's endpoint; not closing it
ok - kill refused renamed block (rc=1)
ok - renamed block 7885559955458 still open (not closed)
ok - kill after restoring title succeeds
ok - block gone after kill; agent_state=missing
ok - repeat kill idempotent
ok - fm-test session removed; sessions now: ["Default","nia12-primary-c16c4b1ab7ad5e22"]
Evidence: tern behaviour suite log

Source: tern behaviour suite log

ok - fm_backend_tern_parse_target: splits '<session-id>:<block-id>' and keeps ids above 2^53 byte-exact
ok - fm_backend_tern_parse_target: refuses empty, non-numeric, signed, spaced, extra-colon and selector-shaped targets
ok - fm_backend_tern_*: a selector-shaped target (@focused) is refused without calling tern
ok - fm_backend_tern_container_ensure: reuses an existing named session and prints its full 64-bit id
ok - fm_backend_tern_container_ensure: creates a missing session by name and returns the new id, leaving other sessions alone
ok - fm_backend_tern_container_ensure: without an override the session is named fm-<home tag>
ok - fm_backend_tern_container_ensure: refuses a tern older than 0.9.4 loudly before touching any session
ok - fm_backend_tern_container_ensure: compares versions numerically (0.10.0 passes the 0.9.4 floor)
ok - fm_backend_tern_container_ensure: an unreadable inventory fails instead of creating a duplicate session
ok - fm_backend_tern_create_task: opens a keep-open tab in the session, renames it to the scoped title, reads it back, prints exact ids
ok - fm_backend_tern_create_task: refuses to place a task in any session other than its own
ok - fm_backend_tern_create_task: an unparseable 'new tab' answer fails without renaming anything
ok - fm_backend_tern_create_task: a failed rename fails the create and closes only the block it made
ok - fm_backend_tern_create_task: refuses a duplicate scoped tab title before creating anything
ok - fm_backend_tern_create_task: a title that never reads back fails the create and closes the new block
ok - fm_backend_tern_target_ready: one ls, true only for the exact session:block pair, exact at 64 bits, false when unreadable
ok - fm_backend_tern_target_ready: the expected label must equal this home's scoped tab title
ok - fm_backend_tern_capture: 'tern capture <block-id> --scrollback --surfaces', trimmed to N lines locally
ok - fm_backend_tern_capture: propagates a failing capture and never reads an absent block
ok - fm_backend_tern_visible_capture: --surfaces without --scrollback, limited to the block's visible rows
ok - fm_backend_tern_capture/visible_capture: a --surfaces JSON object yields its .text before the line trim; other output is kept raw
ok - fm_backend_tern_send_literal: 'tern send <block> text TEXT' with no Enter, even for option-shaped text
ok - fm_backend_tern_send_key: Enter/Escape/Esc/C-c/C-u map to tern's enter/escape/ctrl+c/ctrl+u chords
ok - fm_backend_tern_send_key: a mismatched expected task label sends nothing
ok - fm_backend_tern_send_text_line: one atomic 'tern run' (text plus Enter), no separate key
ok - fm_backend_tern_current_path: reads 'tern process' foreground.cwd without typing into the block
ok - fm_backend_tern_current_path: prints nothing when the process cannot be read
ok - fm_backend_tern_composer_state: empty/pending/unknown from a plain --surfaces capture, never failing the caller
ok - fm_backend_composer_state: routes tern to the tern composer classifier
ok - fm_backend_tern_busy_state: working->busy, idle->idle, waiting_input->blocked (herdr's vocabulary), picking the entry whose pane equals the block id at 64 bits
ok - fm_backend_tern_busy_state: a stale 'working' registration over a shell-only block never reads busy
ok - fm_backend_tern_busy_state: no entry, alive:false, malformed or non-array answers all read unknown
ok - fm_backend_tern_busy_state: tolerates the optional fresh-Lua-state banner above the arrow line
ok - fm_backend_tern_busy_state: no Tern window / failing tern ctl degrades to unknown, never an error
ok - fm_backend_tern_native_state: a hung control endpoint is bounded by FM_BACKEND_TERN_CTL_TIMEOUT and reads unknown
ok - fm_backend_tern_native_state: working|idle|waiting_input from the projected agent list after one inventory check, unknown for an unverified block
ok - fm_backend_tern_native_state/busy_state: a displayed answer with a raw newline inside a string fails agents_json and reads unknown without failing the caller, while the same entries with it escaped read normally
ok - fm_backend_tern_native_state: the projected answer parses (also laid out over several lines), every id survives as an exact decimal string, and the entry whose pane equals the block id supplies the state
ok - fm_backend_busy_state: routes tern to the native agent-state reader
ok - fm_backend_tern_agent_state: agent foreground -> alive, idle shell (incl. --rcfile) -> dead, shell -c / unrelated process -> ambiguous
ok - fm_backend_tern_agent_state: missing only from a good inventory; exited -> dead; moved -> ambiguous; unreadable on any failed read
ok - fm_backend_agent_state: routes tern to the tern process classifier
ok - fm_backend_tern_kill: closes exactly the task block by numeric id, never the session
ok - fm_backend_tern_kill: 0 when the block is already gone, and repeatable
ok - fm_backend_tern_kill: an unreadable inventory fails instead of claiming the block is gone
ok - fm_backend_tern_kill: a failed close is success only when a fresh inventory shows the block gone
ok - fm_backend_tern_kill: refuses (and closes nothing) when the block id now belongs to another session
ok - fm_backend_tern_kill: refuses (and closes nothing) when the block's tab no longer carries the task's title
ok - fm_backend_tern_list_live: lists only this home's scoped task tabs in its own session, as plain fm-<id> labels
ok - fm_backend_visible_capture: routes tern to the viewport read
ok - fm_backend_target_exists: tern is a read-only inventory check
ok - fm_backend dispatcher: send_key, capture and kill route to the tern adapter
ok - fm_backend_tern_send_text_submit: a native idle -> working transition confirms delivery without reading the screen
ok - fm_backend_tern_send_text_submit: waiting_input after Enter counts as a landed submit
ok - fm_backend_tern_send_text_submit: an inconclusive native read falls back to the composer; retries press Enter only and never retype
ok - fm_backend_tern_send_text_submit: a busy agent's queued Enter counts as delivered (shared queued-Enter policy)
ok - fm_backend_tern_send_text_submit: no control endpoint degrades to the shared composer loop
ok - fm_backend_tern_send_text_submit: retries past a popup-placeholder-fill Enter and lands the real second Enter
ok - fm_backend_tern_send_text_submit: a swallowed Enter reports pending after the Enter-only retries
ok - fm_backend_tern_send_text_submit: a failing Enter is retried as Enter only, and reported send-failed when it never lands
ok - fm_backend_tern_send_text_submit: reports 'send-failed' when the block is absent
ok - fm_backend_send_text_submit: routes tern to the native-confirming submit
ok - fm_backend_validate_task_endpoint: a complete tern record validates and keeps 64-bit ids byte-exact
ok - fm_backend_validate_task_endpoint: tern records without an exact binding, with mismatched/non-numeric/overlong/duplicate ids or selector windows are refused
ok - fm-spawn.sh: refuses backend=tern for --secondmate spawns (no per-home lifecycle design is verified)
ok - fm-spawn.sh --backend tern: writes backend/window/tern_*_id/endpoint_task_id with exact ids that pass cleanup validation
ok - fm-spawn.sh --backend tern: a cleared allowlist launch keeps TERM_PROGRAM and the TERN_* identity, drops the rest, and invents nothing
ok - tern_refuse_if_unsafe: accepts only a numeric id listed under exactly its fm-test- name; fails closed on empty, non-numeric, foreign, unlisted or unreadable
ok - tern_refuse_if_unsafe: session ids above 2^53 are compared as exact integers
ok - tern_refuse_if_unsafe: a session hosting $TERN_PANE is never torn down
ok - tern_safe_kill_session: one 'tern kill session <id>' behind the guard, nothing at all when the guard refuses
ok - tern smoke test: skips cleanly with no tern, and with a listing daemon but no window control endpoint, touching nothing
Evidence: backend dispatcher suite log

Source: backend dispatcher suite log

ok - fm_backend_name: FM_BACKEND env > config/backend > default tmux
ok - fm_backend_detect: no markers -> undetected, HERDR_ENV=1 -> herdr, $TMUX -> tmux, CMUX_WORKSPACE_ID -> cmux, nested combinations resolve innermost-first
ok - fm_backend_detect: falls back to __CFBundleIdentifier=com.cmuxterm.app when CMUX_WORKSPACE_ID is absent (signal bundle-id; foreign bundle ids rejected)
ok - fm_backend_detect: the cmux fallback signals are macOS-only (inert on a non-Darwin uname)
ok - fm_backend_detect: an inherited cmux bundle id never outranks $TMUX or HERDR_ENV (tmux/herdr-inside-cmux false positive absorbed)
ok - fm_backend_detect: ancestry fallback matches the lsappinfo-resolved (bundle-id) cmux app pid in the parent chain
ok - fm_backend_detect: ancestry fallback matches a bundle-shaped cmux comm path at any install location when lsappinfo cannot resolve a pid
ok - fm_backend_detect: ancestry fallback stops undetected at launchd (a reparented tmux server never reaches cmux)
ok - fm_backend_name: a fallback-detected cmux prints a NOTICE naming the fallback signal; the primary-marker notice is unchanged
ok - fm_backend_name: verified Herdr and tmux stay silent while experimental cmux remains loud
ok - fm_backend_detect/fm_backend_name: paseo is never auto-detected from PASEO_* markers or its bundle id (tmux default stays silent); only FM_BACKEND or config/backend select it
ok - fm_backend_detect/fm_backend_name: TERM_PROGRAM=rex + REX_BLOCK -> rex (silent); nested tmux/herdr win; REX_BLOCK alone never selects rex; explicit config wins
ok - fm_backend_detect/fm_backend_name: tern is never auto-detected from TERM_PROGRAM/TERN_PANE (tmux default stays silent, a nested tmux or herdr still detects itself); only FM_BACKEND or config/backend select it
ok - fm_backend dispatch tables: tern requires tern+jq+treehouse, has visible capture, declares no push stream
ok - fm_backend_name: an explicit FM_BACKEND or config/backend setting always wins over runtime auto-detection, including an ambient cmux marker
ok - fm_backend_validate: implemented adapters accepted, unknown and blocked codex-app backends refused loudly
ok - zsh: shell-portable backend matching skipped (zsh not found)
ok - bash: fm_backend_source recognizes known backends and rejects unknown ones
ok - fm_backend_source: missing adapter fails before lifecycle continuation
ok - fm_backend_source: unreadable adapter fails before lifecycle continuation
ok - fm_backend_validate_spawn: all implemented lifecycle backends are spawn-supported
ok - fm_meta_get / fm_backend_of_meta: read last key=value and default backend to tmux
ok - fm_backend_resolve_selector: session:window literal, exact task id first, legacy fm-<id> label fallback, ad hoc bare name via tmux list-windows
ok - fm_backend_of_selector: exact task ids, legacy fm-<id> labels, and matching explicit targets inherit metadata backend
ok - fm-send.sh: explicit tmux targets are verified; text types once and submits with Enter
ok - fm-peek.sh: capture-pane invocation and output are byte-identical old vs new
ok - fm-spawn.sh: a project reached through a symlinked prefix (e.g. macOS /tmp -> /private/tmp) does not trip the isolation guard's false refusal
ok - fm-teardown.sh: treehouse return remains compatible while tmux cleanup uses exact selectors
ok - fm-spawn.sh --backend bogus is refused loudly
ok - fm-spawn.sh --backend codex-app is refused
ok - fm-spawn.sh honors FM_BACKEND and refuses an unimplemented value loudly
ok - fm-spawn.sh: an explicit --backend tmux resolves silently and writes no backend= (missing means tmux)
ok - fm-spawn.sh: explicit --backend tmux wins over an ambient HERDR_ENV=1 auto-detect marker
ok - fm-spawn.sh: auto-detect resolves nested tmux-in-herdr to tmux and stays silent end to end
Evidence: teardown endpoint safety log

Source: teardown endpoint safety log

ok - fm-teardown: missing, empty, malformed, ambiguous, and task-mismatched endpoints refuse before every mutation or runtime call
ok - fm-teardown: a concurrent lifecycle action refuses before mutation
ok - fm-teardown: non-pool cleanup ignores unrelated task publication locks
ok - fm-teardown: destructive cleanup serializes with metadata writers
ok - cleanup identity: valid tmux, Herdr, Zellij, Orca, cmux, Paseo, Rex, and tern records validate, inconsistent Rex records refuse, and every empty backend target refuses
ok - cleanup identity: an Orca record's real composite worktree id validates while a separatorless or newline-carrying id refuses
ok - tmux backend: direct empty target returns nonzero without invoking tmux
ok - process cleanup: creation-time PID identity removes only the exact child and preserves the control child
ok - fm-teardown: exact tmux cleanup preserves invalid and prefix-matched neighbors while removing only the recorded target
ok - fm-teardown: a close that genuinely failed refuses and keeps the record naming the surviving endpoint, and the same teardown finishes once the close works
ok - fm-teardown: --force continues past a close it could not make while still reporting it, and the same case refuses without --force
ok - fm-teardown: a close re-read that could not run refuses, while a definitively absent session or server still completes silently
ok - fm-teardown: forced secondmate cleanup still refuses on a child endpoint close that failed
ok - fm-teardown: an Orca close its missing CLI never attempted refuses even under --force, keeping the record naming the terminal
ok - fm-teardown: an already-exited endpoint, and a server that is already gone, still complete cleanup silently
ok - Treehouse locking resolves a bare local origin against its source project, matching the provisioned clone
ok - fm-teardown: a pool slot named by a second task record is never returned, killed, or reset
ok - fm-teardown: a pool slot held by another firstmate home is never returned
ok - fm-teardown: a task that solely holds its slot still returns it
ok - fm-teardown: a pool slot claimed by another task is left alone while the task's own cleanup finishes
ok - fm-teardown: a stale record on a claimed slot retires, then the claimant tears down
ok - fm-teardown: a task's own slot claim, and an unclaimed slot, both still tear down
ok - fm-teardown: an exact recorded endpoint still tears down after changing cwd outside its worktree
ok - Treehouse project locking anchors at the local root for main-home, local-secondmate, and remote-seeded layouts
ok - fm-teardown: a remote-seeded secondmate home returns its own uncontested pool slot
ok - fm-teardown: slot ownership across a remote-seeded home and its local child still refuses
ok - Treehouse project locking still serializes two homes across the remote-seeded boundary
Evidence: Paseo suite log

Source: Paseo suite log

ok - fm_backend_paseo_version_check: accepts the verified minimum (0.8.0)
ok - fm_backend_paseo_version_check: accepts a newer version (0.9.2)
ok - fm_backend_paseo_version_check: refuses an old version loudly
ok - fm_backend_paseo_version_check: refuses loudly when paseo is not found on PATH or at the bundle path
ok - fm_backend_paseo_parse_target: splits '<terminal_id>:<workspace_id>' on the first colon
ok - fm_backend_paseo_scoped_name: scopes a primary task name with firstmate plus root hash
ok - fm_backend_paseo_scoped_name: scopes a secondmate task name with the home marker plus root hash
ok - fm_backend_validate: paseo is a known backend
ok - fm_backend_busy_state: paseo (no native primitive) always reports unknown, same as tmux/zellij/orca/cmux
ok - fm_backend_composer_state: routes paseo to the paseo composer classifier
ok - fm_backend_paseo_daemon_state: reports 'ok' when localDaemon=running and connectedDaemon=reachable
ok - fm_backend_paseo_daemon_state: reports 'down' when 'paseo status' fails
ok - fm_backend_paseo_ensure_running: returns immediately when paseo is already reachable
ok - fm_backend_paseo_create_task: refuses a duplicate terminal name (paseo's own terminal create has no uniqueness check)
ok - fm_backend_paseo_create_task: creates the shared workspace once plus a terminal tab and parses terminal_id/workspace_id
ok - fm_backend_paseo_create_task: refuses, creating nothing, when the terminal or workspace inventory cannot be read
ok - fm_backend_paseo_create_task: adopts the project's live firstmate workspace by cwd+label and adds a tab (never a second workspace)
ok - fm_backend_paseo_create_task: adopts the workspace firstmate itself runs in (PASEO_WORKSPACE_ID) when its cwd is the project, ahead of the title lookup
ok - fm_backend_paseo_create_task: a task for any project becomes a tab in firstmate's own workspace (PASEO_WORKSPACE_ID)
ok - fm_backend_paseo_create_task: a Paseo agent uses the one workspace whose folder is its home, and falls back when that is ambiguous
ok - fm_backend_paseo_workspace_ensure: adopts the shared workspace by its physical or slash-normalized logical cwd
ok - fm_backend_paseo_cli_json: keeps stderr out of parsed JSON and relays it only on failure
ok - fm_backend_paseo_workspace_label: 'firstmate' for the primary home, '2ndmate-<id>' for a secondmate home (no path hash)
ok - fm_backend_paseo_target_ready: fails when the terminal is not found and no expected label is given
ok - fm_backend_paseo_target_ready: verifies the live terminal name against the expected label
ok - fm_backend_paseo_target_ready: rejects a terminal id reused under a different name
ok - fm_backend_paseo_target_ready: recovers a stale terminal id by home-scoped NAME, never by title
ok - fm_backend_paseo_capture: fetches the whole scrollback and trims to N lines locally
ok - fm_backend_paseo_capture: fails when the target terminal is absent
ok - fm_backend_paseo_send_key: passes the key through unchanged to the recorded terminal id
ok - fm_backend_paseo_send_key: C-u goes as the raw 0x15 byte via -l; keys outside paseo's token set are refused, never typed
ok - fm_backend_paseo_send_literal: calls send-keys -l with a -- separator before the literal payload
ok - fm_backend_paseo_send_text_line: sends literal text then submits with Enter
ok - fm_backend_paseo_current_path: actively probes with marked begin/end lines (creation-time-frozen cwd)
ok - fm_backend_paseo_composer_state: a bare '❯' composer row reads empty
ok - fm_backend_paseo_composer_state: real composer text reads pending
ok - fm_backend_paseo_composer_state: reports unknown when the terminal cannot be captured
ok - fm_backend_paseo_send_text_submit: reports 'empty' once the composer row reads empty after one Enter
ok - fm_backend_paseo_send_text_submit: reports 'send-failed' when the target terminal is absent
ok - fm_backend_paseo_kill: closes the task's terminal tab and leaves the workspace alive when its inventory is unreadable
ok - fm_backend_paseo_kill: the last task tab retires firstmate's shared workspace and its own clone's project
ok - fm_backend_paseo_kill: retires the recorded workspace and project when the task tab was already closed
ok - fm_backend_paseo_kill: keeps the workspace while a tab, agent, other title, or firstmate itself uses it, and never retires anything outside this home's clones
ok - fm_backend_paseo: spawn and workspace retirement share one lock; neither acts while another process holds it
ok - fm_backend_paseo_kill: never fails even when terminal kill fails
ok - fm_backend_paseo_list_live: lists only this home's scoped task terminals using plain fm-<id> labels
ok - fm-spawn.sh: an explicit paseo refuses --secondmate (mirrors cmux/Orca); ambient Paseo markers never select paseo
ok - Pi supervision branch claims a paseo stale wake keyed by the task's window= endpoint

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

🔧 **Rebase** - 21 issues found → no changes applied ✅
  • ⚠️ .agents/skills/harness-adapters/references/harness/commandcode.md - merge conflict rebasing onto refs/remotes/no-mistakes-push/tern-backend
  • ⚠️ .agents/skills/operational-home-layout/SKILL.md - merge conflict rebasing onto refs/remotes/no-mistakes-push/tern-backend
  • ⚠️ .agents/skills/stuck-crewmate-recovery/SKILL.md - merge conflict rebasing onto refs/remotes/no-mistakes-push/tern-backend
  • ⚠️ CONTRIBUTING.md - merge conflict rebasing onto refs/remotes/no-mistakes-push/tern-backend
  • ⚠️ README.md - merge conflict rebasing onto refs/remotes/no-mistakes-push/tern-backend
  • ⚠️ bin/fm-backend.sh - merge conflict rebasing onto refs/remotes/no-mistakes-push/tern-backend
  • ⚠️ bin/fm-bootstrap.sh - merge conflict rebasing onto refs/remotes/no-mistakes-push/tern-backend
  • ⚠️ bin/fm-control-lib.sh - merge conflict rebasing onto refs/remotes/no-mistakes-push/tern-backend
  • ⚠️ bin/fm-control.sh - merge conflict rebasing onto refs/remotes/no-mistakes-push/tern-backend
  • ⚠️ bin/fm-spawn.sh - merge conflict rebasing onto refs/remotes/no-mistakes-push/tern-backend
  • ⚠️ bin/fm-supervise-daemon.sh - merge conflict rebasing onto refs/remotes/no-mistakes-push/tern-backend
  • ⚠️ bin/fm-test-run.sh - merge conflict rebasing onto refs/remotes/no-mistakes-push/tern-backend
  • ⚠️ docs/architecture.md - merge conflict rebasing onto refs/remotes/no-mistakes-push/tern-backend
  • ⚠️ docs/configuration.md - merge conflict rebasing onto refs/remotes/no-mistakes-push/tern-backend
  • ⚠️ docs/documentation-audiences.json - merge conflict rebasing onto refs/remotes/no-mistakes-push/tern-backend
  • ⚠️ docs/scripts.md - merge conflict rebasing onto refs/remotes/no-mistakes-push/tern-backend
  • ⚠️ docs/verification/runtime-backends.md - merge conflict rebasing onto refs/remotes/no-mistakes-push/tern-backend
  • ⚠️ tests/fm-backend.test.sh - merge conflict rebasing onto refs/remotes/no-mistakes-push/tern-backend
  • ⚠️ tests/fm-bootstrap.test.sh - merge conflict rebasing onto refs/remotes/no-mistakes-push/tern-backend
  • ⚠️ tests/fm-control.test.sh - merge conflict rebasing onto refs/remotes/no-mistakes-push/tern-backend
  • ⚠️ tests/fm-teardown-endpoint-safety.test.sh - merge conflict rebasing onto refs/remotes/no-mistakes-push/tern-backend

🔧 No changes applied.
✅ Re-checked - no issues remain.

⚠️ **Review** - 0 issues

✅ No issues found.

🔧 No changes applied.
✅ Re-checked - no issues remain.

  • ⚠️ bin/backends/tern.sh:491 - The branch's own verification record contradicts how the adapter parses tern capture --surfaces output. docs/verification/runtime-backends.md:2298 records that tern capture &lt;block&gt; --surfaces on tern 0.9.4 returned JSON {&#34;block&#34;,&#34;text&#34;}. But the adapter header (tern.sh:51-52) and both capture paths treat the output as plain screen text. fm_backend_tern_capture (tern.sh:491-492) pipes the raw output to tail -n, and fm_backend_tern_visible_capture (tern.sh:503-507) trims it to the block's rows. The composer read (tern.sh:515, consumed by fm_backend_tern_composer_state at tern.sh:535-536) inherits that. If the recorded shape is right, every Tern capture is a JSON envelope whose transcript newlines are escaped. In that case the row trim cuts JSON rather than screen rows, the shared composer, dialog and harness-signature classifiers never see real lines, and peek and rendered-tail readers get JSON. None of this errors; it just silently reads as unknown, or shows the wrong text. The smoke test's substring check (tests/fm-backend-tern-smoke.test.sh:122-126) and the fake-CLI fixtures (plain text) cannot tell the two shapes apart. Smallest fix: in one shared helper, when the capture output parses as a JSON object with a string .text, use .text, otherwise use the raw output; apply it before the tail -n in both capture functions. Then make the adapter header or the verification row agree on the real shape.
  • ℹ️ docs/tern-backend.md:45 - The doc says a cleared-environment launch keeps TERM_PROGRAM "on a backend=tern task only". The launch floor in bin/fm-spawn.sh:6440 keeps TERM_PROGRAM for every backend, with no tern condition. The sentence describes a tern-specific behaviour that does not exist; it should say the floor keeps whatever TERM_PROGRAM the pane has, which is tern inside a Tern block.

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

🔧 No changes applied.
2 issues (1 warning, 1 info) still open:

  • ⚠️ bin/backends/tern.sh:159 - This conflicts with a recorded human decision, so it needs your call. On this branch the user chose to fix the earlier simplification finding: narrow FM_BACKEND_TERN_AGENTS_LUA to {pane = a.pane, state = a.state, alive = a.alive}, then update the docs/tern-backend.md Lua snippet and the agent_json fixture to match. The current head still requests eight fields (pane, session, tab, host, state, alive, busy, program). The only consumer, fm_backend_tern_native_state_raw (tern.sh:605-615), reads just pane, state and alive. The docs still describe the wide projection: docs/tern-backend.md:113 (Lua snippet) and docs/tern-backend.md:120 ("two short names (host, program)"). Concrete risk: if host or program is a user-chosen label that carries a raw newline, every native read degrades to unknown. That is the exact failure 6f5555de set out to prevent. The rebuild intent says obsolete-run fix commits were deliberately dropped, so this may be intentional. Confirm whether the narrowing decision still stands. If it does, narrow the projection plus the doc snippet and fixture. If not, record that it was superseded.
  • ℹ️ docs/tern-backend.md:168 - The Active limits bullet says the away-mode supervisor accepts "only tmux and herdr supervisor panes". But bin/fm-supervise-daemon.sh:218 sets FM_SUPERVISOR_SUPPORTED_BACKENDS="tmux herdr rex", and docs/configuration.md lists rex as supported too. The tests/fm-daemon.test.sh:80 failure message has the same omission ("away mode supports only tmux and herdr"). Change both to name tmux, herdr and rex.

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

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 6 of 9 scenarios driven live against the product
Scenario Result Live Evidence
Spawning from inside a Tern block (TERM_PROGRAM=tern and TERN_PANE set, no TMUX, nothing configured) lands in default tmux silently, with no backend= in meta and no Tern session created ✅ pass live live-ambient-spawn-state.txt, live-ambient-attempt1-state.txt
FM_BACKEND=tern explicitly selects Tern: spawn opens a tab titled fm-<hometag>-<id> and meta records backend=tern with exact session/tab/block ids ✅ pass live live-explicit-env-state.txt
config/backend=tern explicitly selects Tern ✅ pass live live-config-backend-spawn.log
The --backend tern flag explicitly selects Tern, and teardown closes the task tab ✅ pass live live-backend-flag-spawn.txt
Adversarial: renaming a task's Tern tab by hand makes teardown refuse to close the block and keep the task records (non-force) ✅ pass live live-renamed-tab-refusal-noforce.txt, live-renamed-tab-refusal.txt (with --force the close is still refused and records are removed, which is the documented --force contract)
With the task title restored, teardown closes exactly the task block and removes records ✅ pass live live-tern-teardown-closes.txt
A tmux or herdr started inside a Tern block still detects itself, and Paseo stays explicit-only ⏸️ untested no The prior payload did not establish a live result: only the hermetic tests/fm-backend.test.sh covered this. Starting a real Herdr client inside a Tern block needs a Tern window, and this host's displa…
The unrelated timeout library change and its test are removed from the PR, and the branch is based on upstream main ⏸️ untested no The prior payload did not establish a live result. This is a repository-content constraint with no runtime surface, and it was checked only with git diff against origin/main (empty diff; merge-base ==…
Tern native agent state is read through the window control endpoint (real smoke test) ⏸️ untested no tern ctl state needs a Tern window control endpoint. On this host tern reports 'no GPU adapter' and cannot open a window, and a headless tern daemon has no window, so the smoke test skipped. Run…
  • bash tests/fm-backend.test.sh (includes test_backend_tern_is_never_autodetected and the paseo never-autodetected case)
  • bash tests/fm-backend-tern.test.sh (includes fm_backend_tern_kill refusal when the tab title changed)
  • bash tests/fm-backend-tern-smoke.test.sh (skipped cleanly: the host's Tern daemon has no window control endpoint)
  • bash tests/fm-teardown-endpoint-safety.test.sh
  • Live: bin/fm-lab-home.sh create lab home with a private tmux socket, a real git project and a disposable origin; real bin/fm-spawn.sh with ambient TERM_PROGRAM=tern TERN_PANE=2, no TMUX, no FM_BACKEND and no config/backend
  • Live: private tern daemon --socket &lt;lab&gt;/ternsock/d.sock with TERN_CONFIG_DIR inside the lab; real bin/fm-spawn.sh with FM_BACKEND=tern, then config/backend=tern, then --backend tern
  • Live: tern rename &lt;block&gt; hand-renamed, then bin/fm-teardown.sh &lt;id&gt; without --force (refuses, keeps records), with --force (refuses the close, removes records), and after restoring the title (closes exactly the task block)
  • git diff --stat origin/main HEAD -- bin/fm-timeout-lib.sh &lt;timeout tests&gt; (empty) and merge-base == origin/main df9eb03a

✅ No issues found.

  • Live validation: ✅ go - 4 of 7 scenarios driven live against the product
Scenario Result Live Evidence
Ambient TERM_PROGRAM=tern and TERN_PANE with no explicit choice keep the default backend (tmux), including when nested in tmux ✅ pass live tern-selection.txt: selected=tmux in both ambient cases
FM_BACKEND=tern or config/backend=tern selects tern and passes spawn validation; config/backend=tmux beats ambient Tern markers ✅ pass live tern-selection.txt; fm-backend.log ('tern is never auto-detected ... only FM_BACKEND or config/backend select it')
Tern adapter against the real tern daemon: create a task block in its own fm-test- session, verify it by label, send a line, capture readable screen text ✅ pass live tern-live-adapter.txt
Adversarial: hand-renaming a task's tab makes kill refuse (nonzero) and leaves the block open; after the title is restored, kill closes it and a repeat kill succeeds ✅ pass live tern-live-adapter.txt ('kill refused renamed block (rc=1)', 'renamed block ... still open')
Capture output that is a JSON {block,text} envelope is reduced to .text before the line trim ⏸️ untested no The prior payload did not establish a live result. The real tern 0.9.4 on this host returned plain text from tern capture --surfaces, so the JSON branch was only exercised through the fake-CLI behav…
Native agent state through the Tern window control endpoint (Carly lua projection of pane/state/alive) ⏸️ untested no tern ctl state fails (/tmp/tern.sock connection refused): no Tern window or tern serve control endpoint runs on this headless host, and starting a GUI window is out of reach here. Live native stat…
Timeout library change is excluded and Paseo integration is preserved ⏸️ untested no The prior payload did not establish a live result. This was a diff-composition check (no timeout files in git diff) plus the Paseo behaviour suite (48 ok). Paseo has no locally runnable app on this ho…
  • Backend selection through fm_backend_name + fm_backend_validate_spawn with a clean env: TERM_PROGRAM=tern TERN_PANE=7 alone; the same markers inside $TMUX; FM_BACKEND=tern; config/backend=tern; and config/backend=tmux alongside the Tern markers
  • Live driver against the real tern 0.9.4 daemon in a guarded fm-test-gate-&lt;pid&gt; session: container_ensure, create_task, target_exists with matching and mismatched labels, send_text_line, raw tern capture --surfaces compared with fm_backend_tern_capture/visible_capture, composer/agent/busy/native state, tern rename of the task tab then fm_backend_kill, restore the title then kill, idempotent re-kill, guarded session cleanup
  • bash tests/fm-backend-tern-smoke.test.sh (skipped: no window control endpoint)
  • bash tests/fm-backend-tern.test.sh (72 ok)
  • bash tests/fm-backend.test.sh (34 ok)
  • bash tests/fm-teardown-endpoint-safety.test.sh (27 ok)
  • bash tests/fm-backend-paseo.test.sh (48 ok)
  • git diff --name-only 9fe25bca..HEAD | grep -i timeout (no timeout files)
✅ **Document** - passed

✅ No issues found.

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

✅ No issues found.

@chsong1 chsong1 changed the title feat(bin): add experimental tern runtime backend feat(backends): add experimental tern runtime backend Oct 20, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @chsong1. This is a thorough adapter: exact u64 ids, a refusal to close a hand-renamed tab, and a live run against a real tern 0.9.4 daemon with the GPU-dependent row honestly marked untested.

What I checked on head e5b34869 against main 45dd50a5: the diff adds bin/backends/tern.sh and wires tern into backend dispatch, bootstrap, busy classification, control, supervision, crew-state, and the test runner families. It also changes bin/fm-timeout-lib.sh so timeout/gtimeout resolve through type -P. Nothing touches .github/workflows, and I found no network calls, secret handling, or CI-script tampering. The attestation binds this head, and live validation is go, 6 of 7. I approved this head's first-time fork runs: CI 39359241849 and Require no-mistakes 39359241814.

Contract-class: new-default (my own read). This backend is not explicit-only. fm_backend_detect now returns tern whenever TERM_PROGRAM=tern and TERN_PANE are set, so a captain running firstmate inside a Tern block with no config/backend gets spawns routed into the experimental tern backend, where main would route them to tmux. A loud notice and an opt-out don't make that opt-in. Separately, the fm-timeout-lib.sh change runs on every home, not just Tern ones. It looks like a safe fix for omp's timeout builtin, but it isn't part of the backend. A new-default change doesn't auto-merge: once CI is green, it goes to Kun to decide.

VISION.md: One captain aligns (no new captain-facing surface). Authority is in tension: auto-detection "assumes consent" where VISION asks for an option to enable, although main already auto-detects herdr and cmux the same way. Scripts vs agents aligns. Restart aligns (ids live in metadata, verified against the live tree). Delegation aligns (guarded kill refuses ambiguity). Vendor aligns (another session manager, version-gated at 0.9.4, behind the shared adapter contract). Scope aligns, but the timeout change is bundled in.

Options, if you'd like this to take the auto-merge path instead of waiting on Kun's decision: make tern explicit-only (drop the fm_backend_detect arm, so only --backend tern, FM_BACKEND=tern, or config/backend select it), and consider splitting the fm-timeout-lib.sh fix into its own PR. Neither is required. As it stands, the PR goes to Kun as a new-default decision once CI is green.

Status: waiting on CI. Nothing is needed from you unless CI comes back red or you choose one of the options above.

@chsong1 chsong1 changed the title feat(backends): add experimental tern runtime backend feat(backends): add experimental explicit-only Stencil Tern backend Oct 22, 2026
@chsong1

chsong1 commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

Updated this PR to make Tern explicit-only and removed the unrelated timeout changes. The workflows for the latest head (5dab171f) are marked action_required. Could you approve the latest runs and re-review when convenient? Thanks!

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @chsong1, that's exactly the shape I suggested.

I re-read head 5dab171f against main df9eb03a:

  • Explicit-only now holds. fm_backend_detect has no tern arm, and the comment says why: TERM_PROGRAM/TERN_PANE leak into descendants. TERM_PROGRAM is forwarded only on tern tasks. Your live row shows an ambient Tern block landing in default tmux with no backend= in meta.
  • The fm-timeout-lib.sh change is gone.
  • Shared-file edits are tern-gated or comments: busy-lib's native-busy arm, spawn's dispatch arms and secondmate refusal, the meta allow-list, the daemon refusal and test-runner routing.
  • The attestation binds this head, and live validation is go (6 of 9). The native-agent-state row is honestly marked untested because the host had no GPU.

Fork CI approved: I read the diff (38 files). There are no .github changes, no network calls (only a MISSING_MANUAL install URL), and no credential handling. The SECRET_TOKEN hits are allowlist test fixtures. I approved CI 39721461302 and Require no-mistakes 39721461289 and 39721499723.

Contract-class: opt-in (my own read, changed from new-default). Nothing changes unless --backend tern, FM_BACKEND=tern or config/backend selects it. VISION.md per rule: One captain aligns · Authority now aligns (explicit grant only) · Scripts aligns · Restart aligns (u64 ids in meta, verified against the live tree) · Delegation aligns (guarded kill refuses a renamed tab) · Vendor aligns (another session manager, version-gated, behind the shared adapter contract) · Scope aligns (the bundled timeout fix is out).

Status: waiting on CI. Nothing is needed from you unless it comes back red. If it's green, this can take the opt-in auto-merge path.

@chsong1 chsong1 changed the title feat(backends): add experimental explicit-only Stencil Tern backend feat(backends): add experimental explicit-only tern runtime backend Oct 22, 2026
@chsong1

chsong1 commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

Updated this PR through no-mistakes at 36b04861721bd74424fa4a3bfae02ae321d94711.

  • Tern is explicit-only: --backend tern, FM_BACKEND=tern, or config/backend. Ambient TERM_PROGRAM=tern/TERN_PANE no longer selects it.
  • Rebased onto upstream main, preserving the upstream backend integrations. The follow-up review fixes normalize capture JSON .text before trimming, narrow the native-state projection to pane/state/alive, and align the TERM_PROGRAM/rex documentation and tests.
  • The unrelated timeout fix is split into fix(bin): resolve timeout/gtimeout to executable paths via type -P #7637 (head 1a042e3). This PR contains no timeout files; the companion contains only the timeout library and its regression test.

Validation: both heads have matching fresh no-mistakes attestations, with Review/Test/Document/Lint completed. The final Tern evidence records passing focused Tern, backend-dispatch, teardown-safety and Paseo suites, plus live explicit/default selection and real-daemon capture/renamed-tab refusal. Live native agent state remains untested without a window control endpoint; JSON-envelope normalization has behavioral-test coverage, not a live JSON-producing backend on this host. The timeout suite and before/after stdout, exit-status and timeout-bound scenarios passed, including a real omp builtin reproduction.

The earlier broad local portable attempt was not clean (fixture/environment failures and a one-hour timeout); the evidence does not claim a full local-suite pass. Latest-head GitHub CI and Require no-mistakes workflows for both PRs currently report action_required and await maintainer approval. The green checks on the earlier Tern head do not cover this new head.

This now targets the opt-in auto-merge path described in your review, subject to the current head's checks and maintainer decision. No merge was performed.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @chsong1. Splitting the timeout fix into #7637 and keeping Tern explicit-only makes this a clean opt-in backend.

I re-read head 36b04861 against main 9fe25bca:

  • Explicit-only still holds after the rebase onto Rex. fm_backend_detect has no tern arm, only the comment explaining why (TERM_PROGRAM/TERN_PANE leak into descendants). There are no fm-timeout-lib.sh changes in this diff.
  • Shared-file edits are tern-gated or comment-only: dispatch arms in fm-backend.sh/fm-spawn.sh, the tern secondmate refusal, the relaunch meta keys, herdr|rex|tern in busy-lib's native-busy arm, the supervisor daemon refusal, and test-runner routing. The one non-gated line adds TERN_* names to the launch-env floor. That loop only runs under the opt-in config/launch-env-allowlist, and only forwards a name already set in the pane.
  • The attestation matches 36b04861, and live validation is go (4 of 7). Native agent state and JSON-envelope capture are honestly marked untested live and are covered by behavioral tests.

Fork CI approved: I read the full diff (36 files). There are no .github changes and no network calls (only the MISSING_MANUAL install URL). The SECRET_TOKEN/eval hits are an allowlist test fixture with fixed names. I approved CI 39756953388 and Require no-mistakes 39756953127 and 39757004485. Both no-mistakes checks have passed. CI is still queued and running.

Contract-class: opt-in (my own read, unchanged). Nothing changes unless --backend tern, FM_BACKEND=tern or config/backend selects it. VISION.md per rule: One captain aligns · Authority aligns (explicit grant only) · Scripts aligns · Restart aligns (u64 ids in meta, revalidated against the live tree) · Delegation aligns (guarded kill refuses a renamed tab) · Vendor aligns (version-gated, behind the shared adapter contract) · Scope aligns (the timeout fix is split out).

Status: waiting on CI, not on you. If it comes back green and the PR stays mergeable, this takes the opt-in merge path.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @chsong1. Kun merged #7639 (Rex push events) to main as d906d442, and this PR now has a merge conflict with it. It's small: one doc paragraph in docs/architecture.md (around line 292). Main now names both Herdr's and Rex's push-event sections, and your side adds tern to the list of backends that don't support secondmate spawns. Keep both: main's Rex wording plus your tern entry. Everything else merges cleanly.

I can't resolve this for you without breaking the no-mistakes attestation, which binds your head 36b04861. Could you rebase onto d906d442 and re-raise with git push no-mistakes? While you're there, please check that the new Rex event-wait path in fm-backend.sh/fm-watch.sh leaves tern on the polling path (no has_push/events_capable arm).

Separately, Behavior portable serial 2 on run 39756953388 was the known 30-minute cancel (#7255), not your change. I re-ran it. The rest of CI was green.

Contract-class (my read, unchanged): opt-in. Tern is explicit-only. VISION: unchanged, every rule aligns.

Status: waiting on you for the rebase. Once the new head is green and the attestation matches, this takes the opt-in merge path.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @chsong1 for rebasing past the docs/architecture.md conflict. That one is gone.

I read head 5f26300d against main e930d960. Two things keep this from merging right now, and both sit with you:

  • A new one-line conflict in bin/fm-spawn.sh. Kun merged feat(opencode): add OpenCode 2 support with version-gated launch, plugins, and exit #7336 (OpenCode 2) right after your push. preserve_relaunch_meta's key list now has opencode_version after effort, and your side adds tern_session_id tern_tab_id tern_block_id after rex_block_id. Keep both. Everything else merges cleanly.
  • The attestation is for an older head. The PR body's no-mistakes attestation still names 36b04861, so PR must be raised via no-mistakes fails on 5f26300d.

Could you rebase onto e930d960 and re-raise with git push no-mistakes? That fixes both at once. The other 19 CI jobs are green on this head.

My read is unchanged. Contract-class: opt-in. Tern is explicit-only: fm_backend_detect has no tern arm, and the shared-file edits are tern-gated or comments. VISION: every rule aligns. Once the re-raise lands green with a matching attestation, I'll merge it.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @chsong1 for the re-raise. The new head 7ea0662d carries a matching no-mistakes attestation, the timeout-lib change is gone from this PR, and tern stays explicit-only.

One thing blocks it, and it sits with you: the branch is based on 6c87d7b (#7703), so it doesn't include #7518 (the explicit-only T3 Code backend, 3004ccb), which landed on main just before. GitHub reads the PR as conflicting, so no CI ran on this head. A local merge into current main 147b2672 conflicts in 19 files. As far as I can see, almost all of them are the same pattern: main added t3code where your side adds tern. Examples are FM_BACKEND_KNOWN/FM_BACKEND_SPAWN and the backend= comment list in bin/fm-backend.sh, plus the matching arms and lists in fm-spawn.sh, fm-control*.sh, fm-busy-lib.sh, fm-composer-lib.sh, fm-crew-state.sh, fm-supervise-daemon.sh, fm-afk-launch.sh, fm-test-run.sh, the README, the docs and tests/fm-backend.test.sh / tests/fm-bootstrap.test.sh. In each spot, keep both backends.

Could you rebase onto 147b2672 and re-raise with git push no-mistakes? I can't resolve it for you without breaking the attestation on your head.

My read on this head is unchanged. I checked it myself, not just the description: contract class opt-in. fm_backend_detect has no tern arm, and inherited TERM_PROGRAM=tern/TERN_PANE markers are ignored. VISION aligns on every rule. There are no .github changes and no network calls beyond the MISSING_MANUAL install URL.

Status: waiting on you for the rebase. Once the rebased head is green with a matching attestation, this takes the opt-in merge path.

Tern is selected only by `--backend tern`, `FM_BACKEND=tern`, or
`config/backend`; runtime auto-detection no longer routes a spawn into it.
TERM_PROGRAM=tern and TERN_PANE reach every descendant process of a Tern
block, including a tmux server or Herdr client started inside it, so an
inherited marker never proves the captain chose Tern.

- bin/fm-backend.sh: drop the tern arm from fm_backend_detect and the
  auto-detected tern NOTICE from fm_backend_name, which became unreachable
  with the arm.
- Replace the tern detect-precedence and auto-detect-notice tests with
  test_backend_tern_is_never_autodetected, mirroring the Paseo case, and drop
  the Tern-marker unsets that only guarded detection hermeticity.
- docs/tern-backend.md: replace "Runtime detection" with "Selection is
  explicit"; fm-spawn.sh and adapter headers, architecture, configuration,
  README, and the operational-home-layout skill now list tern beside zellij,
  orca, and Paseo as never auto-detected.
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @chsong1 for the rebase. That's exactly what was needed.

What I checked on head 8c506579: it sits on 147b2672, and the no-mistakes attestation binds this head. GitHub reports it mergeable, and it still merges cleanly into today's main 43cd3b7e (#7265 touched none of your files). I compared the rebased commits with 7ea0662d one by one. Seven are identical. The other three change only where your tern entries now sit next to main's t3code in the backend lists, case arms, meta keys, tests and docs. Both backends are kept everywhere. Tern is still explicit-only: fm_backend_detect has no tern arm, and the README no longer lists it under auto-detected. There are no .github changes and no new network or credential paths.

CI: everything is green except serial 1, which hit main's 30-minute job cap. That cap comes from main, not from this branch, and it stays until main's own fix lands. I re-ran the failed job.

Contract-class (mine): opt-in. Tern runs only when someone picks it with --backend tern, FM_BACKEND=tern or config/backend. VISION: aligns on every rule. It's an experimental adapter with its own verification record, it ships as an option to enable, and it doesn't tie the distro to one session manager.

Next step: this isn't waiting on you. Once serial 1 is green and the branch is still clean against main, it takes the opt-in merge path.

@kunchenguid
kunchenguid merged commit bab667c into kunchenguid:main Oct 25, 2026
36 of 37 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: this is merged. Thank you @chsong1 — really appreciate you taking the time on this. Tern lands as an explicit-only experimental backend (bab667cf).

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