Single-commit clean baseline after security scrub of niche-tells, project codenames, internal jargon, and contributor-email leaks. Contents: - 100 Rust crates (_primitives/_rust/) - 37 agent manifests (_manifests/) + generated specs (_generated/) - 67 user-invocable skills (skills/) - 33 hooks (hooks/) - Composition blocks (_blocks/) - Documentation (docs/, README.md) - TS adapter packages (_ts_packages/) - Assembler (_assembler/) - Roles (_roles/) - Templates (_templates/) - Forgejo CI (.forgejo/) Author: Denis Parfionovich <info@greendragon.info> License: see LICENSE.
4.2 KiB
4.2 KiB
API — REST Conventions (verbs, status codes, resources, idempotency, ETag)
HTTP-level contract for resource-oriented APIs. Pairs with api-openapi-first.md (spec as SSoT), api-versioning-pagination-ratelimit.md (list + version policy), and auth-oauth2-oidc.md / auth-sessions.md (principal + scopes).
When to include
- Public or partner JSON-over-HTTP API where clients are heterogeneous (mobile, SPA, third-party integrations, curl).
- Internal service boundary that you want reviewable by humans without generated tooling.
- Any API that must degrade gracefully through an HTTP cache / proxy / API gateway.
What it declares
- Resource naming: plural nouns, lowercase, kebab-case (
/invoices,/invoice-items/{id}), no verbs in path. Nested resources ≤2 levels deep (/invoices/{id}/items); beyond that flatten with query filters. One canonical URL per resource — never two paths for the same entity. - Verbs (RFC 9110):
GETsafe + idempotent,HEADmetadata only,PUTfull replace + idempotent,PATCHpartial (JSON Merge Patch RFC 7396 OR JSON Patch RFC 6902, pick one per API),POSTcreate / non-idempotent action,DELETEidempotent. Non-CRUD actions →POST /resource/{id}:action(Google AIP-136) or a child resource — neverGET /do-thing. - Status codes — pick from this set, no creativity:
200 OK,201 Created(+Locationheader),202 Accepted(async),204 No Content,301/308(moved),400 Bad Request(validation),401 Unauthorized(no/invalid credential),403 Forbidden(authenticated but not allowed),404 Not Found,409 Conflict(optimistic-lock / duplicate),410 Gone,412 Precondition Failed(If-Match mismatch),415 Unsupported Media Type,422 Unprocessable Entity(semantic validation),429 Too Many Requests,500 Internal Server Error,502/503/504(upstream).418is a joke, not a status. - Error body: RFC 9457 Problem Details —
{ "type": "https://api.example.com/errors/invoice-not-found", "title": "...", "status": 404, "detail": "...", "instance": "/invoices/42", "errors": [{"field":"amount","code":"negative"}] }. Content-Typeapplication/problem+json. StabletypeURI = machine key;title= human;detail= this instance. - Idempotency-Key header (Stripe / IETF draft-ietf-httpapi-idempotency-key-header): required on
POSTthat creates/charges. Server stores(key, route, response)for ≥24 h and replays on retry. Different body with same key →422. Missing key on mutatingPOST→400for strict APIs, accept + warn for lenient. - Conditional requests (RFC 9110 §13):
ETagon every resource representation (strong"abc123"unless you truly serve byte-equivalent variants). Clients sendIf-Match: "abc123"onPUT/PATCH/DELETE— server replies412on mismatch.If-None-Match+304 Not ModifiedonGETfor cache revalidation.Last-Modifiedas a weaker fallback only. - Content negotiation:
Accept,Accept-Language,Accept-Encodinghonoured. Defaultapplication/json; charset=utf-8. Version media types (application/vnd.example.v2+json) ONLY if you commit to header-based versioning — seeapi-versioning-pagination-ratelimit.md. - HATEOAS / hypermedia: OPTIONAL. Include a
_links/linksobject per resource when the API is explicitly browsable (HAL, JSON:API, Siren) — it's not required for typed SDKs. Document the choice inopenapi.yamland stay consistent. - Safe-by-default surface:
GETnever mutates.DELETEis idempotent — repeated calls return204even if the row is already gone.PUTrequires the FULL representation; partial field onPUT=400.
References
- RFC 9110 (HTTP Semantics), RFC 9111 (HTTP Caching), RFC 9457 (Problem Details, 2023), RFC 7396 / 6902 (Merge Patch / JSON Patch), RFC 5988 + 8288 (Web Linking) [E1 — IETF standards-track].
- Google AIP (https://google.aip.dev/) and Microsoft REST API Guidelines (https://github.com/microsoft/api-guidelines) — production-grade conventions [E2].
api-openapi-first.md— encode this block as the machine-readable SSoT;api-versioning-pagination-ratelimit.md— list, cursor, and version policy.- Evidence grade [E2] — every rule here is deployed across Stripe, GitHub, Google, Microsoft production APIs.