Skip to content

feat(bin): add duplex Signal process-event adapter - #2680

Closed
FocalFactotum wants to merge 25 commits into
kunchenguid:mainfrom
FocalFactotum:fm/firstmate-signal-duplex-adapter-v4
Closed

FocalFactotum wants to merge 25 commits into
kunchenguid:mainfrom
FocalFactotum:fm/firstmate-signal-duplex-adapter-v4

Conversation

@FocalFactotum

@FocalFactotum FocalFactotum commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Intent

Rebase the existing upstream pull request #2680 (feat(bin): add duplex Signal process-event adapter, author FocalFactotum) onto the current kunchenguid/firstmate:main, preserving its accepted Signal adapter behavior, and update that exact PR rather than opening a replacement. This is a history-refresh task, not authorization to redesign or broaden the feature. The captain explicitly authorized rebasing the PR, including the necessary history rewrite of its existing FocalFactotum topic branch fm/firstmate-signal-duplex-adapter-v4, but did not authorize merging it.

The PR was verified open at head c801060a71e3e609f8a9ea6caa3cf594c2decbd2 on the FocalFactotum fork before any change, with the same identity throughout. The 19 original commits (starting "Add optional Signal process-event adapter" through "no-mistakes(document): Document Signal capture envelope") were manually rebased onto current upstream main and verified: bin/fm-procevent-signal.sh and tests/fm-procevent-signal.test.sh landed byte-identical to the original PR, and only bin/fm-procevent.sh required semantic conflict resolution against upstream commit 1fbc7bb "feat(bin): add trusted process-event extension bindings" - the Signal PRs generation-bound readiness feature (ready/unready/wait-ready commands, the readiness token export in cmd_start, and every ready_file cleanup site) was grafted onto upstreams new extension-owner branching rather than colliding with it; one redundant duplicate runner-file write (superseded by upstreams own equivalent write already present on the built-in-adapter branch) was dropped as the only genuine removal. Documentation/verification-history conflicts were resolved by keeping both sides content (upstream extension-binding verification entries alongside the Signal verification entries) and the dispatch-table conflict by keeping every command from both sides. All required guarantees were preserved: privacy/home-local temp and data-dir isolation, lifecycle retire-before-every-signal-cli-operation and restore-after-success-or-failure, bounded command timeouts, single-owner idempotent retirement/re-arm, stdin-only message bytes (never argv), the generation-bound readiness boundary, validated-account JSON-RPC attribution, and inert-when-unconfigured behavior. Focused Signal/process-event tests (tests/fm-procevent-signal.test.sh, tests/fm-procevent.test.sh), the full changed-file repository test set (bin/fm-test-run.sh --changed --base upstream/main, 38/38 passed), bin/fm-lint.sh, and bin/fm-doc-audience-check.sh all passed against that manual rebase (note: on this macOS sandbox, TMPDIR must be set to an already-canonical path for process-event claim-acquisition tests to pass, due to a pre-existing upstream symlink-canonicalization requirement in fm_procevent_claim_state_root_identity that is unrelated to this PR and reproduces identically on unmodified upstream/main - not something to fix here).

A prior no-mistakes run in this same home (01M0FMVP6QQGZ0MZ24WH8K9P5H) had already rebased, reviewed, tested, documented, linted, and pushed this exact PR as of 2026-08-26 (onto upstream main as it stood then, 07bf0c8) before being cancelled at the CI step; that push is the still-live c801060 PR head. Per explicit firstmate/captain direction, do not force or rewrite the no-mistakes gate and do not use the separately-verified manual rebase (preserved read-only at local ref backup/fm-firstmate-signal-duplex-adapter-v4-rebased-2141998, and pr2680-orig-head/c801060 preserved verbatim) as the submitted branch content. Instead this run starts fresh from the unchanged gate-known/remote head c801060 so the pipeline itself performs the deterministic rebase onto current main, review, fixes, documentation, lint, push, and PR update end to end - mirroring the same history-preserving reconciliation already used for PR 3176. The manual rebase remains available only as read-only evidence of already-verified Signal semantics if a conflict-resolution decision needs it.

Do not copy from or reference the captain-private untracked Signal prototype, read any private Signal configuration/identifiers/account state/messages, or run a real Signal account. Update only the existing PR 2680 branch (fm/firstmate-signal-duplex-adapter-v4 on the FocalFactotum fork) - never open a duplicate PR. Push only to that configured fork. Do not merge; leave the PR ready for the captains explicit merge decision.

What Changed

  • Add an optional duplex Signal adapter that captures configured group messages and sends attributed replies through private, home-local Signal state.
  • Add generation-bound ready, unready, and wait-ready process-event commands so sends can retire the receiver and restore it only after the replacement runner is ready.
  • Document Signal configuration and lifecycle guarantees, with focused coverage for routing, ownership, privacy, timeouts, interruption recovery, and receive restoration.

Risk Assessment

✅ Low: The optional adapter is well-bounded and inert when unconfigured, and the reviewed generation, interruption, home-confinement, message-pinning, ownership, and readiness paths preserve the accepted behavior and documented limitations.

Testing

The supplied baseline reported prior focused, changed-file, lint, and documentation checks green. This phase independently ran the two targeted executable suites and a fake-account CLI flow. Testing exposed and fixed a TERM timing deadlock, after which interruption re-arm, home confinement, pinned message bytes, readiness, privacy, routing, and generic replacement semantics passed without accessing a real Signal account.

Evidence: Fake-account public CLI send and restored-receive transcript
$ fm-procevent-signal send team message.txt
sent: Signal message
json-rpc attribution, route, and body: valid
receive registration restored and generation-ready: yes
private temporary files remaining: no
signal-cli argv (home path normalized):
--data-dir <effective-home>/state/signal/data listAccounts
--data-dir <effective-home>/state/signal/data jsonRpc --receive-mode=manual
--data-dir <effective-home>/state/signal/data listAccounts
--data-dir <effective-home>/state/signal/data -o json receive -t -1 --max-messages 1 --ignore-attachments --ignore-stories --ignore-avatars --ignore-stickers

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

🔧 **Rebase** - 2 issues found → auto-fixed ✅
  • ⚠️ bin/fm-procevent.sh - merge conflict rebasing onto refs/remotes/no-mistakes-push/fm/firstmate-signal-duplex-adapter-v4
  • ⚠️ docs/verification/process-event-sources.md - merge conflict rebasing onto refs/remotes/no-mistakes-push/fm/firstmate-signal-duplex-adapter-v4

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

🔧 **Review** - 3 issues found → auto-fixed (2) ✅
  • 🚨 bin/fm-procevent-lib.sh:152 - Repeated generic registration no longer creates a fresh generation. For a live terminal source, registering the identical argv now preserves the source inode, so the old runner's claim identity still matches and it can retire the supposedly replacement registration. This also contradicts the new executable regression in tests/fm-procevent.test.sh. Restore replace-on-register semantics here and keep Signal-only idempotence in cmd_arm_locked.
  • 🚨 bin/fm-procevent-signal.sh:457 - After cmd_send_locked retires the receive source, HUP, INT, or TERM during account discovery, prefixing, or JSON-RPC send invokes interrupt_send, which disables the EXIT trap and exits without restore_source. This leaves inbound Signal registration absent, violating the approved restore-after-failure behavior. Route catchable interruptions through restoration while preserving the signal exit status, and cover the observable re-arm in the interruption regression.
  • 🚨 bin/fm-procevent-signal.sh:89 - A private file is created by mktemp before its path is added to PRIVATE_TEMPFILES. If a trapped signal arrives while the shell waits for mktemp, Bash can run the deferred trap after mktemp returns but before the array assignment, so cleanup cannot find the newly created sensitive file. Establish a cleanup-owned path before creation, such as an invocation-private directory, so every catchable interruption removes the file.

🔧 Fix: Restore process-event generations and interruption-safe Signal rearm
2 errors still open:

  • 🚨 bin/fm-procevent-signal.sh:67 - The intent requires "privacy/home-local temp and data-dir isolation" and says Signal mapping, credentials, and state remain home-local, but these checks reject only final-component symlinks. For example, $FM_HOME/config or $FM_HOME/state can be a symlink outside the home; the adapter then accepts the mode-0600 routing file or creates signal/data there and invokes signal-cli against external state. Validate canonical confinement beneath the effective home before reading configuration or creating Signal state.
  • 🚨 bin/fm-procevent-signal.sh:400 - The message-file safety check is separated from the actual cp by route validation, receive retirement, and account discovery. A concurrent replacement can swap the validated regular file for a symlink, causing arbitrary target contents to be sent without error. Open the file once, validate the opened descriptor as a regular non-symlink source, and stage bytes from that pinned descriptor.

🔧 Fix: Confine Signal state and pin outbound message bytes
✅ Re-checked - no issues remain.

✅ **Test** - passed

✅ No issues found.

  • TMPDIR=&#34;$PWD/.no-mistakes-test-tmp&#34; bash tests/fm-procevent-signal.test.sh - initially reproduced the deadlock, then passed after the fix
  • TMPDIR=&#34;$PWD/.no-mistakes-test-tmp&#34; bash tests/fm-procevent.test.sh - passed, including replacement-generation and runner ownership behavior
  • Manual fake-account bin/fm-procevent-signal.sh send check - verified sanitized output, valid account/group/body attribution, home-local data directory, identifier-free argv, restored generation-ready receive, private-temp cleanup, and retirement
✅ **Document** - passed

✅ No issues found.

🔧 **Lint** - 1 issue found → auto-fixed ✅
  • ⚠️ linter found issues (exit code 1)

🔧 Fix: Captain: fix Signal adapter ShellCheck findings
✅ Re-checked - no issues remain.

✅ **Push** - passed

✅ No issues found.

@greptile-apps

greptile-apps Bot commented Aug 23, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Reviews (3): Last reviewed commit: "no-mistakes(lint): Captain: fix Signal a..." | Re-trigger Greptile

@FocalFactotum
FocalFactotum force-pushed the fm/firstmate-signal-duplex-adapter-v4 branch from 75a573c to c801060 Compare August 26, 2026 07:04
FocalFactotum and others added 25 commits August 30, 2026 09:49
…3247)

* feat(extensions): bind trusted external process-event adapters

* no-mistakes(review): Enforce owner and remote-home conformance

* no-mistakes(review): Enforce serialized remote extension package lifecycle

* no-mistakes(review): Enforce identity-conditional extension retirement

* no-mistakes(review): Serialize extension retirement and recover crash cuts

* no-mistakes(review): Unify retirement worker and lifecycle lock ownership

* no-mistakes(review): Harden extension lifecycle retirement serialization

* no-mistakes(review): Unify extension registration and overridden-state lifecycle boundaries

* no-mistakes(document): Clarify built-in-only captain answer routing

* no-mistakes(lint): Captain: fix extension binding ShellCheck findings

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes(review): Use isolated UID mapping for owner conformance

* no-mistakes(review): Captain: remove forbidden CI ownership wrapper

* no-mistakes(review): Serialize extension binding publication

* no-mistakes(review): Document ordinary CI owner-fixture exclusion

* no-mistakes(review): Quarantine orphaned handshake descendants

* no-mistakes(test): Fix orphan attribution

* no-mistakes(test): Harden process tracker baseline

* no-mistakes(test): Harden detached descendant attribution

* no-mistakes(test): Use exact invocation-group cleanup

* no-mistakes(test): Bound remote conformance transport crossings

* no-mistakes(test): Parallelize isolated extension conformance tests

* no-mistakes(test): Lifecycle suite still exceeds deadline

* feat(extensions): bind trusted external process-event adapters

* no-mistakes(review): Enforce owner and remote-home conformance

* no-mistakes(review): Enforce serialized remote extension package lifecycle

* no-mistakes(review): Enforce identity-conditional extension retirement

* no-mistakes(review): Serialize extension retirement and recover crash cuts

* no-mistakes(review): Unify retirement worker and lifecycle lock ownership

* no-mistakes(review): Harden extension lifecycle retirement serialization

* no-mistakes(review): Unify extension registration and overridden-state lifecycle boundaries

* no-mistakes(document): Clarify built-in-only captain answer routing

* no-mistakes(lint): Captain: fix extension binding ShellCheck findings

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes(review): Use isolated UID mapping for owner conformance

* no-mistakes(review): Captain: remove forbidden CI ownership wrapper

* no-mistakes(review): Serialize extension binding publication

* no-mistakes(review): Document ordinary CI owner-fixture exclusion

* no-mistakes(review): Quarantine orphaned handshake descendants

* no-mistakes(test): Fix orphan attribution

* no-mistakes(test): Harden process tracker baseline

* no-mistakes(test): Harden detached descendant attribution

* no-mistakes(test): Use exact invocation-group cleanup

* no-mistakes(test): Bound remote conformance transport crossings

* no-mistakes(test): Parallelize isolated extension conformance tests

* no-mistakes(test): Lifecycle suite still exceeds deadline

* no-mistakes(review): Split extension conformance and forward remote transfer input

* no-mistakes(review): Forward malformed remote payloads through fm-on

* no-mistakes(review): Bound extension coordinator failure cleanup

* no-mistakes(test): Skip repeated orphan sweep in coordinator children

* no-mistakes(test): Queue isolated extension sections through bounded workers

* no-mistakes(test): Bound extension coordinator lane cleanup

* no-mistakes(test): Split remote lifecycle coordinator sections

* no-mistakes(test): Coordinator probes pass; aggregate deadline remains

* no-mistakes(test): Launch extension sections concurrently

* no-mistakes(test): Fix coordinator marker publication

* no-mistakes(test): Stabilize extension binding coordinator timing

* no-mistakes(lint): Fix extension binding ShellCheck warnings

* fix(extensions): prove invocation cleanup before retirement

* no-mistakes(review): Harden process-event inbox confinement

* no-mistakes(review): Preserve legacy capture parity

* no-mistakes(review): Protect external registry staging

* no-mistakes(test): Stabilize bounded extension conformance aggregate

* no-mistakes(document): Document external evidence confinement

* no-mistakes(ci): CI phase fixed. The failure was a flaky fixture in `tests/fm-remote-transport-lanes.test.sh`: its “fresh/in-use” staging directory had no live owner identity, so the real worker correctly reaped it once the 1-second age boundary elapsed on slower CI. The fixture now records the active test shell’s exact PID/start identity and cleans those records before removal. Verified: `bash tests/fm-remote-transport-lanes.test.sh` exits 0 with all checks passing; `git diff --check` passes. Provider check retrieval was also retried successfully, resolving the selected manual CI finding. Changed file: `tests/fm-remote-transport-lanes.test.sh`

* no-mistakes(review): Harden extension staging and lifecycle reservation

* no-mistakes(review): Harden external staging and lifecycle reservations

* no-mistakes(review): Wire capture helper into remote conformance

* no-mistakes(review): Pin external capture handoff and signal failures

* no-mistakes(review): Bind pinned capture authority to inherited descriptor

* no-mistakes(review): Harden descriptor-bound capture authority

* no-mistakes(review): Harden core capture reservation authority

* no-mistakes(review): Harden capture reservation boundaries

* no-mistakes(review): Harden capture reservations and cleanup

* no-mistakes(review): Harden capture handoff and reservation cleanup

* no-mistakes(review): Bind capture handoff to claim descriptors

* no-mistakes(review): Release lifecycle locks after host crashes

* no-mistakes(review): Pin reservation recovery to recorded state roots

* no-mistakes(review): Reject control bytes in claim state roots

* no-mistakes(test): Stabilize extension capture descriptor handoff

* no-mistakes(document): Document extension capture authority boundary

* no-mistakes(lint): Fix ShellCheck extension binding warnings

* no-mistakes(ci): CI phase result: fixed `bin/fm-procevent.sh` by initializing the shared `capture_state` sentinel for built-in adapters under `set -u`. This prevents normal built-in captures from aborting before publication. Verified: `bash -n bin/fm-procevent.sh` and `git diff --check` pass. The focused process-event suite was run locally but stopped earlier at a local detached-runner claim failure (`reconcile never claimed the registered source`), before the CI-reported post-capture path; CI evidence confirms the fixed unset-variable failure affected the failing remote, board, watcher, and process-event checks

* no-mistakes(document): Correct extension namespace creation timing

* no-mistakes(lint): Initialize capture locals for ShellCheck
@FocalFactotum
FocalFactotum force-pushed the fm/firstmate-signal-duplex-adapter-v4 branch from c801060 to 01f1926 Compare August 30, 2026 15:34
@FocalFactotum

Copy link
Copy Markdown
Contributor Author

Closing: the trusted external process-event extension bindings from #3247 are the right home for a personal Signal adapter, so this built-in version is no longer the plan.

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