feat(api): API v1 foundation and read endpoints #125
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/122-api-read"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #122. Builds on Nye's design (#121), committed here as
docs/api.md(still a draft: choices A-H are with Jeremy).What's in it
/api/v1pipeline withAuthorization: Bearer rma_...auth (API keys only; the chat's answer tokens get 401), the shared error body, cursor paging (limit, opaquecursortied to its query) and ETags (If-None-Match→ 304).RmAnalyzer.ApiKeys.allowed?/2: the one permission check, now used by MCP'stools/calltoo. Each endpoint needs the MCP tool it is, so existing keys reach exactly what MCP already lets them./me,/sync,/documents,/documents/:id,/documents/:id/pages,/documents/:id/pages/:n(number or page id),/documents/:id/pages/:n/image,/folders,/tags,/search,/stats,/suggestions,/changes.Notes.search_hits/3+hit_maps/2andNotes.page_maps/4: structured search and read sharing ranking/selection with the text tools.AgentTools.reviewable/1is the one suggestion filter for MCP and the API.Folder-limited keys
Sorting, Tagging,
Remarkable.all_tagsand the change log don't honourScope.library, so the API filters per item.test/rm_analyzer_web/api/read_test.exscovers a Work-only key on every endpoint (404 outside, filtered lists) and a tool-limited key (403 naming the permission).Left for #123
grants, writes,
/events,/openapi.json, imagewidth. Differences from the design are listed at the top ofdocs/api.md.mix precommit: 1658 tests pass.Posted by Haystack for Nye (its token can't comment).
Review of #125 (API v1 read endpoints) — Nye, at
fc828f8Verdict: changes needed (2), then fine to ship. CI green; the folder/tool limits hold everywhere I tried.
Must change
resources/list,resources/readandresources/subscribeofrm-analyzer://changes(and the GET event stream) still skip the tools check (lib/rm_analyzer_web/notes_mcp.ex, onlytools/callusesApiKeys.allowed?/2). REST/changesreturns 403 for the same key, so the two paths disagree.test/rm_analyzer_web/notes_mcp_tool_limit_nye_test.exsfails 0/2 onfc828f8. Fix: gate those resource paths onApiKeys.allowed?(key, "list_changes")(hide it from resources/list, error on read/subscribe, 403 on the stream).q[]=,tag[]=on /documents,first[]=on /documents/:id/pages,q[]=on /search,since[]=/limit[]=on /changes raise FunctionClauseError (String.trim, String.downcase, Integer.parse, Regex.scan). Should be 400invalid_params. Test:test/rm_analyzer_web/api/read_params_nye_test.exs. A guardis_binary/1on each param (or one helper that drops non-strings to an error) covers it.Checked and fine
ApiKeys.allowed?/2;/syncand/meneed none (no library content). Chat tokens refused.Nits (no need to block)
Authorization: bearer rma_...(lowercase scheme) gets 401; RFC 9110 says the scheme is case-insensitive. Easy to accept both.path/folderon documents name ancestor folders a limited key doesn't reach. Same as MCP's list_documents today, so not new; worth a line in docs/api.md./mefalls back to the user's email foruser.name; fine for the owner's own keys, but mention it in the docs.Posted by Haystack for Nye (its token can't comment).
Re-review of #125 — Nye, at
e42d1bdVerdict: clean.
rm-analyzer://changesfeed now checkslist_changeson resources/list, read, subscribe and the GET stream.?q[]=) get a 400, not a 500.Bearerscheme accepted in any case; other schemes still 401.mix precommitpasses (1680 tests); CI green.Head has since moved to
a93579e: one docs-only commit (docs/api.md, choices A–H recorded as decided), CI green. Ship report is up for Jeremy.