Skip to content

moooon

Motir

Vibe your whole project. Bring an idea — Motir's three AI layers plan it, track it, and ship it, end to end. You're looking at Motir, built in Motir.

  • Vibe Project
  • Open Source
  • AI Agent
  • AI Loop
1
requests
0
upvotes
145
planned
1,361
shipped

Motir · Work items

MOTIR-3337Done

motir-core: the seam — motirAiClient lesson reads behind a permission-checked server route

The core half of the read: client methods on motirAiClient and the server-side route that calls them, with the permission checked before the call is made.

  • Client — list and detail, following the shape of the neighbours (getJob, getOrgUsage): typed response, malformed-body handling, the project id threaded through, no new error convention.
  • Route — checks the view permission first, then calls. A caller without it gets a refusal and no lesson data is fetched at all; the check does not sit between the fetch and the render.

The permission guards the DATA. This is the card where "hide the section in the client" would be an easy and wrong implementation — lessons are distilled from a project's planning work and can carry specifics about it, so a payload that ships them to anyone who can load the page has already disclosed them, whatever the component renders.

A motir-ai outage degrades, it does not break the settings page. The AI-planning settings surface has three working groups on it; a lessons read that throws would take all of them down. Follow the graceful-degradation precedent already in the codebase — a failed read costs the section its content, not the page.

Acceptance criteria

  • motirAiClient gains list and detail methods matching the neighbouring methods' shape, typing and error handling.
  • A server route exposes them, checking the view permission before any call to motir-ai.
  • A request without the permission is refused and no upstream call is made, asserted.
  • The response carries only what the surface needs; nothing about other projects is reachable through it.
  • A motir-ai failure or timeout degrades the section and leaves the rest of the AI-planning settings page working, asserted.
  • Unit tests for the client, route tests for the guard; no UI in this card.

Context refs

  • motir-core lib/ai/motirAiClient.tsgetJob, getOrgUsage, embedTexts; the envelope, typing and malformed-body conventions to follow.
  • motir-core app/api/projects/[key]/ai-settings/route.ts — the neighbouring project-scoped settings route.
  • motir-core lib/permissions/resolve.ts — how the key is checked.
  • MOTIR-3335 — the upstream endpoint this calls.
  • MOTIR-3336 — the key this checks.