Skip to content

feat: add document API endpoints to uteke-serve - #441

Merged
ajianaz merged 4 commits into
developfrom
feat/doc-api-endpoints
Jun 22, 2026
Merged

ajianaz merged 4 commits into
developfrom
feat/doc-api-endpoints

Conversation

@ajianaz

@ajianaz ajianaz commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add HTTP API endpoints for all document operations in uteke-serve, ensuring CLI and API feature parity.

Endpoints Added

Method Endpoint Description
POST /doc/create Create/upsert document (slug, content, tags, parent)
POST /doc/get Get document by id or slug
POST /doc/list List documents (roots_only, parent filter, namespace)
POST /doc/search Hybrid/semantic/FTS document search
POST /doc/move Move document to new parent
DELETE /doc/delete?id= Delete document with cascade

Request/Response Format

All POST endpoints accept JSON body. All endpoints accept namespace parameter.

POST /doc/create

{ "slug": "guide", "content": "# Guide\n...", "title": "Guide", "tags": ["wiki"], "parent": "parent-slug", "namespace": "default" }
→ { "id": "uuid", "slug": "guide" }

POST /doc/get

{ "id": "uuid" } or { "slug": "guide" }
→ { "id", "slug", "title", "content", "tags", "parent_id", "depth", "has_children", ... }

POST /doc/list

{ "namespace": "default", "limit": 20, "roots_only": false, "parent": "parent-slug" }
→ [{ "id", "slug", "title", "depth", "has_children", ... }]

POST /doc/search

{ "query": "authentication", "mode": "hybrid", "namespace": "default", "limit": 10 }
→ [{ "document": {...}, "chunk_heading", "chunk_snippet", "score", "mode" }]

POST /doc/move

{ "id": "uuid", "new_parent": "new-parent-slug" }
→ { "moved": 1 }

DELETE /doc/delete?id=uuid&namespace=default

→ { "deleted": true, "subtree_size": 3 }

Changes

ajianaz added 2 commits June 22, 2026 15:58
Endpoints:
- POST /doc/create — create/upsert document with optional parent
- POST /doc/get — get document by id or slug
- POST /doc/list — list documents (roots_only, parent filter)
- POST /doc/search — hybrid/semantic/fts document search
- POST /doc/move — move document to new parent
- DELETE /doc/delete — delete document with cascade

All endpoints accept namespace parameter. Added to startup banner.
- cli-reference.md: add doc search, move, --tree, --roots-only, --parent flags
- cli-reference.md: add doc HTTP endpoints to API table
- AGENT.md: add Function ↔ API ↔ CLI parity table for v0.4.0
- Document all 6 doc functions with corresponding CLI + API endpoints
- Note breadcrumbs, descendants, export as CLI-only (intentional)
@github-actions

github-actions Bot commented Jun 22, 2026 •

Copy link
Copy Markdown

🔍 Cora AI Code Review

❌ Blocked — critical issues found.

🔴 Error (4)

  • crates/uteke-server/src/main.rs:1264 — In the new /doc/delete handler, every Err(e) from uteke.doc_delete(...) is mapped to a 500 response. This differs from the nearby /doc/get and /doc/move handlers, which translate not-found cases into 404s. As written, deleting a non-existent document will likely be reported as an internal server error instead of a client-facing not-found condition.
  • crates/uteke-server/src/main.rs:1231 — The /doc/move handler only special-cases errors containing "not found"; all other failures become 500. Earlier in this diff and in the changelog, move-related validation errors are expected, such as maximum depth enforcement and invalid parent relationships. Returning 500 for those user-input errors misclassifies request problems as server faults.
  • crates/uteke-server/src/main.rs:1202 — DocListParams.limit is deserialized directly from the request and passed to uteke.doc_list* without any upper bound. A client can request an arbitrarily large limit, which risks excessive DB work, response size, and memory use on the server.
  • crates/uteke-server/src/main.rs:1219 — The /doc/search handler forwards req_data.limit directly into uteke.doc_search(...) with no validation. Because search can involve semantic ranking and FTS work, an unbounded limit exposes the endpoint to unnecessarily expensive queries and oversized responses.

Review powered by cora-cli · BYOK · MIT

Comment thread crates/uteke-server/src/main.rs Fixed
Comment thread crates/uteke-server/src/main.rs Fixed
format!("document slug '{}' already exists", req_data.slug),
)
} else if e.to_string().contains("maximum")
|| e.to_string().contains("parent")
(Method::Post, "/doc/get") => match read_body::<DocGetRequest>(req.as_reader()) {
Ok(req_data) => match resolve_doc_id(&req_data) {
Ok(id_or_slug) => match uteke.doc_get(id_or_slug, ns(&req_data.namespace)) {
Ok(Some(doc)) => ctx.ok_response_for(req, &doc),
}
},
Err(e) => ctx.error_response_for(req, 400, e),
},
ns(&req_data.namespace),
req_data.limit,
&req_data.mode,
) {
@ajianaz
ajianaz merged commit 7fbf7a7 into develop Jun 22, 2026
8 of 9 checks passed
@ajianaz
ajianaz deleted the feat/doc-api-endpoints branch June 22, 2026 10:02
ajianaz added a commit that referenced this pull request Aug 13, 2026
* feat: add document API endpoints to uteke-serve

Endpoints:
- POST /doc/create — create/upsert document with optional parent
- POST /doc/get — get document by id or slug
- POST /doc/list — list documents (roots_only, parent filter)
- POST /doc/search — hybrid/semantic/fts document search
- POST /doc/move — move document to new parent
- DELETE /doc/delete — delete document with cascade

All endpoints accept namespace parameter. Added to startup banner.

* docs: update cli-reference and AGENT.md for v0.4.0 doc API

- cli-reference.md: add doc search, move, --tree, --roots-only, --parent flags
- cli-reference.md: add doc HTTP endpoints to API table
- AGENT.md: add Function ↔ API ↔ CLI parity table for v0.4.0
- Document all 6 doc functions with corresponding CLI + API endpoints
- Note breadcrumbs, descendants, export as CLI-only (intentional)

* fix: use correct parse_query_param function name in doc endpoints

* fix: remove unused DocDeleteParams struct

---------

Co-authored-by: ajianaz <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants