Repository navigation
Conversation
3c45b00 to
d2273b8
Compare
5bb3944 to
830627e
Compare
|
Automated reminder: thanks for the PR! This branch currently has a merge conflict with the base branch. When you get a chance, please rebase onto (or merge) the latest base branch, resolve the conflict, and push. After that, checks will re-run and the PR will get looked at again. Noted for firstmate#839 at |
|
Automated reminder: this PR still looks blocked on a rebase or merge conflict fix. If you are still interested, please rebase onto the current base branch, resolve the conflict, and push. If I do not hear back, I may close this as inactive. |
|
I am closing this because it has been waiting on a rebase or merge-conflict fix since 2026-07-23, and I have not seen a comment or push since then. If you still want to keep working on this, please reopen it or open a new PR and mention this one. Happy to take another look when there is an update. |
What Changed
bin/fm-portal-*scripts (shared lib plus config, poll, request, reply, followup, and link commands) that let the watcher poll a private portal for captain messages and deliver replies, with body-free durable records, token redaction in state, lock-guarded replay-safe state transitions, and wiring into bootstrap, session-start, guards, andfm-watch.sh.tests/fixtures/fake-portal.pyand a 12-scenariotests/fm-portal-connector.test.shend-to-end suite — plus a newportal-respondskill and updated configuration, architecture, and supervision-protocol docs.Risk Assessment
✅ Low: The fix round resolves the claimed-request duplicate-execution error and the poll-cost warning exactly as instructed, with behavior-parity in the rewritten scan paths, deterministic regression tests that fail under the old behavior, and only one minor defense-in-depth nuance remaining; the feature stays opt-in and inert by default.</risk_rationale>
Testing
Ran the new fm-portal-connector end-to-end suite (12/12 scenarios pass with a real loopback HTTP fake portal) plus the six other test suites modified by this change (all pass), and captured a manual CLI transcript demonstrating the complete connector lifecycle — install, poll signal, claimed-work no-re-offer, read, idempotent reply verified server-side by body hash and acknowledgement, durable body-free records, token redaction, and disable back to inert.
Evidence: End-to-end portal connector CLI transcript (install → message → poll → read → reply → server-verified ack → redaction → disable)
$ fm-portal-poll.sh portal-message 1 $ fm-portal-request.sh mark-queued 1 $ fm-portal-poll.sh (no output — queued work is not re-offered) $ fm-portal-request.sh read 1 {"id":1,"body":"Please summarize the deploy status for me.","created_at":"2026-07-21T00:00:01.000Z"} $ fm-portal-reply.sh 1 --text-file reply.txt 1 $ GET /_test/stats { "reply_count": 1, "reply_hashes": ["c8e364aa…"], "acknowledged_ids": [1] } reply body hash matches sha256 of the agent's reply text: VERIFIED captain message 1 acknowledged as delivered: VERIFIED token absent from all connector state files (config file mode 600)Evidence: fm-portal-connector test suite output (12/12 scenarios pass)
Pipeline
Updates from git push no-mistakes
⏭️ **intent** - skipped
✅ No issues found.
🔧 **Rebase** - 2 issues found → auto-fixed ✅
docs/configuration.md- merge conflict rebasing onto origin/maindocs/scripts.md- merge conflict rebasing onto origin/main🔧 Fix applied.
✅ Re-checked - no issues remain.
bin/fm-portal-lib.sh:531- Every poll cycle spawns O(records) jq processes while holding FMP_LOCK: the resume scan (fm-portal-poll.sh:60) runs fmp_record_load (~4 jq calls) per record, and fmp_prune_completed re-validates and re-reads state for every record up to three more times (age loop, count pipeline, removal pipeline). At the default retention cap of 256 completed records this is roughly 2,000+ jq invocations per 30-second cycle, and the whole poll runs under the watcher'stimeout $CHECK_TIMEOUT(default 30s, fm-watch.sh:467). On a slow or loaded host a full retention window can push the poll past the timeout, in which case it is killed before printing anything — notifications stall silently with noportal-erroremitted. Consolidating each directory scan into a single jq pass (or caching validation results within one run) would remove the risk without changing behavior.bin/fm-bootstrap.sh:757- Dead code in portal_mode_setup's invalid-config branch:[ "$had_artifacts" -eq 0 ] || return 0immediately followed byreturn 0— both paths return 0, so the conditional (and the had_artifacts bookkeeping feeding it) has no effect and can be dropped.bin/fm-portal-followup.sh:40- A task'sportal_request=meta link can be stranded when the reply completes via the poller's resume path instead of a fm-portal-followup.sh retry: followup exits 5 when an earlier request blocks the cumulative ack (fm-portal-reply.sh:181-184), leaving the link in place; if the poller later completes the record, nothing re-notifies the agent to retry followup, and fm-portal-link.sh then refuses to link any new request to that task ("task is already linked to another portal request") until the meta is manually cleaned. Consider having the poller's linked/replying recovery, or recover-unclaimed, clear meta links whose record is already complete.bin/fm-portal-reply.sh:90- fm-portal-reply.sh holds FMP_LOCK across all network I/O (acquired at line 90, released only by the EXIT trap): the POST can take up to ~24s (max-time 8s x 3 attempts) plus the ack round-trip. A concurrent watcher poll spins on the lock for that whole time and can itself be killed by CHECK_TIMEOUT. The state is durable so this self-heals on the next cycle, but releasing the lock around the two HTTP calls (state transitions are already replay-safe) would avoid the wasted watcher cycles.bin/fm-portal-poll.sh:8- fm-portal-poll.sh's header documents the output contract asportal-message <id> [<id> ...](and fm-watch.sh's mark-queued handler parses multiple ids), but the implementation only ever prints the single oldest pending id (line 209-221). Harmless — the consumer handles both — but the contract comment overstates what is emitted.🔧 Fix: Never re-offer claimed portal work; single-pass record scans
1 info still open:
bin/fm-portal-lib.sh:346- fmp_records_scan's|| return 1on the jq invocation does not fire for an invalid record in the middle of the directory: verified on both jq 1.6 and 1.7,error("invalid record")on a non-final input prints to stderr and jq still exits 0 (only a failing final input yields exit 5). The fail-closed contract therefore rests entirely on the line-count backstop, which a contrived compensating corruption (one record file holding two schema-valid concatenated JSON values plus one invalid file) could balance out. Practical impact is negligible — records/ is owner-only 0600/0700 state and anyone able to craft such files could simply write a fully valid record instead — but replacingerror("invalid record")withhalt_errorwould make jq abort with a nonzero status at the first invalid record, making the documented "any invalid payload fails the whole scan" guarantee unconditional.✅ **Test** - passed
✅ No issues found.
bash tests/fm-portal-connector.test.sh— all 12 end-to-end scenarios pass against the hermetic fake portalbash tests/fm-bootstrap.test.sh(exit 0)bash tests/fm-session-start.test.sh(exit 0)bash tests/fm-turnend-guard.test.sh(exit 0)bash tests/fm-x-mode.test.sh(exit 0)bash tests/fm-arm-pretool-check.test.sh(exit 0)bash tests/fm-supervision-instructions.test.sh(exit 0)Manual end-to-end CLI walkthrough: started tests/fixtures/fake-portal.py, ran fm-portal-config.sh install/status, injected a captain message, fm-portal-poll.sh emitted the body-freeportal-message 1signal, mark-queued suppressed re-offer (head-commit behavior), fm-portal-request.sh read printed the body, fm-portal-reply.sh delivered the reply — verified on the server via sha256 body hash and acknowledged_ids — then confirmed body-free durable record, token redaction in state, and inert behavior after disable✅ **Document** - passed
✅ No issues found.
🔧 Fix: suppress SC2016 false positive on portal record schema jq
1 warning still open:
🔧 Fix: clear stale portal task links after deferred-ack poller completion
1 warning still open:
✅ **Push** - passed
✅ No issues found.