Skip to content

Expose POST /v1/write on the local loopback API (draft posts/articles from the stub) #53

Description

@telivity-otaip

Why

personality-protect api is a loopback stub today (GET /health, POST /v1/filter only). Extending it to the product path — write — unblocks a browser extension, editor plugins, and local automation without ever leaving 127.0.0.1.

Context

  • Stub lives in src/personality_protect/api.py
  • Product path: write / write_article (see cli.py write command)
  • Privacy: bind 127.0.0.1 only; never accept remote hosts by default; never upload corpus

Proposed API

POST /v1/write
Content-Type: application/json

{
  "topic": "Contoso Ledger exceptions",
  "points": "- Name one owner\n- Keep the rollout boring",
  "channel": "post",          // or "article"
  "k": 4,
  "adapter": false,
  "profile": "default"
}

Response (Contoso-safe receipt + draft text for local use only):

{
  "ok": true,
  "channel": "post",
  "adapter": "none",
  "text": "",
  "local_only": true
}

Acceptance criteria

  • POST /v1/write drafts via the same code path as the CLI write command
  • Supports --channel post|article equivalents
  • Rejects empty topic/points with 400
  • Still binds 127.0.0.1 only; document that remote bind is out of scope
  • /health lists the new endpoint
  • Unit tests with a stubbed/mock model (no MLX download in CI) — mirror demo / mock patterns
  • README CLI reference updated under Status / API

Out of scope

  • Browser extension UI (separate issue)
  • Auth / TLS / LAN exposure

Difficulty

Medium — wire existing write path into the HTTP handler + tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions