Agent-agnostic review loop: upload_pdf, external_ref, MCP subscriptions and webhooks #109

Merged
jfro merged 2 commits from feat-104-agent-loop into main 2026-11-27 20:01:21 +00:00
Owner

What changed

PR #109 meets #104's done-when: an agent uploads its own plan PDF tagged plan-xyz@v1 and learns it was reviewed by poll, signed webhook or MCP subscription, with external_ref on each change. The red-then-green test (C13), CI and 1611 local tests (C14) pass, and the URL guard was tried against real TLS hosts.

Fixes #104

Red, then green

  • The agent loop test drives #104's done-when: an agent with no templates uploads its own plan PDF tagged plan-xyz@v1, is told it moved to Reviewed by list_changes, a signed webhook and an MCP subscription notification, and sees external_ref on the change; unsafe upload URLs and webhook URLs are refused.: bash -c 'source ~/.rmenv && eval "$(mise activate bash --shims)" && mix test test/rm_analyzer/agent_loop_test.exs'
    • fails on the base (09e0b2e): exit 1
    • passes on the branch (3f6f010): exit 0

Checks

  • CI on PR #109's head passed (unused-deps check, warnings-as-errors compile, format, full mix test), and mix precommit passed locally with 1611 tests; the pinned SafeUrl request was also tried against real https hosts (example.com 200, w3.org PDF 200, localhost refused). (Upper Wolfjaw): bash -c 's=$(curl -s -H "Authorization: token $FORGEJO_TOKEN" https://git.knope.dev/api/v1/repos/jfro/rm-analyzer/commits/$(git rev-parse HEAD)/status | jq -r .state); echo "CI: $s"; [ "$s" = success ]', exit 0
  • Reviewed the diff and SafeUrl's address filtering and pinning; the loop test and the full suite (1611 tests) pass here, and the shipping answers hold. Not tried: real tablet, live MCP clients, SSE behind the production proxy. (Prover): bash -c 'source ~/.rmenv && eval "$(mise activate bash --shims)" && mix test test/rm_analyzer/agent_loop_test.exs', exit 0

Shipping it

  • Goes live when it merges: no. Merging to main only runs CI; images are built from v* tags by Jeremy's own release run.
  • Undo: a revert puts it back.
  • Not tried on the real thing: A real tablet sync and real MCP clients: subscriptions over SSE and webhook delivery ran through Plug.Test and Req.Test stubs, not Jeremy's reMarkable or a live agent, and the SSE stream wasn't tried behind the production reverse proxy.
  • For later: It adds a migration (document_refs plus webhook columns) that a code revert won't drop, and MCP sessions live in memory, so a restart drops subscriptions. pdf_base64 tops out near 5 MB; agents on the home LAN need RM_AGENT_URLS_ALLOW_PRIVATE=true.

Prover

Passed (Sonnet): Reviewed the diff and SafeUrl's address filtering and pinning; the loop test and the full suite (1611 tests) pass here, and the shipping answers hold. Not tried: real tablet, live MCP clients, SSE behind the production proxy.

Every command above was run by Fortysix's Basecamp itself, on the branch named.

## What changed PR #109 meets #104's done-when: an agent uploads its own plan PDF tagged plan-xyz@v1 and learns it was reviewed by poll, signed webhook or MCP subscription, with external_ref on each change. The red-then-green test (C13), CI and 1611 local tests (C14) pass, and the URL guard was tried against real TLS hosts. Fixes #104 ## Red, then green - The agent loop test drives #104's done-when: an agent with no templates uploads its own plan PDF tagged plan-xyz@v1, is told it moved to Reviewed by list_changes, a signed webhook and an MCP subscription notification, and sees external_ref on the change; unsafe upload URLs and webhook URLs are refused.: `bash -c 'source ~/.rmenv && eval "$(mise activate bash --shims)" && mix test test/rm_analyzer/agent_loop_test.exs'` - fails on the base (09e0b2e): exit 1 - passes on the branch (3f6f010): exit 0 ## Checks - CI on PR #109's head passed (unused-deps check, warnings-as-errors compile, format, full mix test), and mix precommit passed locally with 1611 tests; the pinned SafeUrl request was also tried against real https hosts (example.com 200, w3.org PDF 200, localhost refused). (Upper Wolfjaw): `bash -c 's=$(curl -s -H "Authorization: token $FORGEJO_TOKEN" https://git.knope.dev/api/v1/repos/jfro/rm-analyzer/commits/$(git rev-parse HEAD)/status | jq -r .state); echo "CI: $s"; [ "$s" = success ]'`, exit 0 - Reviewed the diff and SafeUrl's address filtering and pinning; the loop test and the full suite (1611 tests) pass here, and the shipping answers hold. Not tried: real tablet, live MCP clients, SSE behind the production proxy. (Prover): `bash -c 'source ~/.rmenv && eval "$(mise activate bash --shims)" && mix test test/rm_analyzer/agent_loop_test.exs'`, exit 0 ## Shipping it - Goes live when it merges: no. Merging to main only runs CI; images are built from v* tags by Jeremy's own release run. - Undo: a revert puts it back. - Not tried on the real thing: A real tablet sync and real MCP clients: subscriptions over SSE and webhook delivery ran through Plug.Test and Req.Test stubs, not Jeremy's reMarkable or a live agent, and the SSE stream wasn't tried behind the production reverse proxy. - For later: It adds a migration (document_refs plus webhook columns) that a code revert won't drop, and MCP sessions live in memory, so a restart drops subscriptions. pdf_base64 tops out near 5 MB; agents on the home LAN need RM_AGENT_URLS_ALLOW_PRIVATE=true. ## Prover Passed (Sonnet): Reviewed the diff and SafeUrl's address filtering and pinning; the loop test and the full suite (1611 tests) pass here, and the shipping answers hold. Not tried: real tablet, live MCP clients, SSE behind the production proxy. Every command above was run by Fortysix's Basecamp itself, on the branch named.
upload_pdf adds an agent's own PDF (base64, or a public https URL fetched
through SafeUrl: pinned, private ranges refused, no redirects, capped).
make_pdf and upload_pdf take external_ref, shown by list_documents,
read_pages, list_changes and webhooks. Agent keys get an MCP session with
a subscribable rm-analyzer://changes resource and an SSE stream, and each
key can have a signed webhook (Settings -> MCP) delivered by an Oban job.

Closes #104
Settings: key row buttons wrap below on narrow screens
All checks were successful
CI / test (pull_request) Successful in 1m51s
0407403097
Author
Owner

Screenshots (example data: a key named "Planner agent" with a webhook to https://example.com/hooks/rm-analyzer; the secret shown is from a throwaway dev DB).

desktop-error

desktop-error

desktop-secret

desktop-secret

desktop-row

desktop-row

mobile-secret

mobile-secret

mobile-row

mobile-row

Screenshots (example data: a key named "Planner agent" with a webhook to https://example.com/hooks/rm-analyzer; the secret shown is from a throwaway dev DB). **desktop-error** ![desktop-error](https://git.knope.dev/attachments/6623da51-a69e-44fa-aaba-a96b7b2fd64a) **desktop-secret** ![desktop-secret](https://git.knope.dev/attachments/c841344c-867d-4213-b0c3-2f1d2ae27029) **desktop-row** ![desktop-row](https://git.knope.dev/attachments/b331c50f-cdb4-4970-acc1-39a0783520c2) **mobile-secret** ![mobile-secret](https://git.knope.dev/attachments/fab5da09-67b0-4fc0-8552-b5278ff63c1a) **mobile-row** ![mobile-row](https://git.knope.dev/attachments/12a06716-2169-42e7-8b44-001c86a532c3)
jfro merged commit d5c6420a42 into main 2026-11-27 20:01:21 +00:00
jfro deleted branch feat-104-agent-loop 2026-11-27 20:01:21 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jfro/rm-analyzer!109
No description provided.