feat: two-store reconciler with safe repair and cost measurement (grade 5, track 2)

This commit is contained in:
2026-11-20 05:01:20 +03:00
parent 1c3011bf28
commit 60e8f4474b
36 changed files with 807 additions and 212 deletions
+7 -1
View File
@@ -53,7 +53,13 @@ func (h *Handler) DownloadAttachment(w http.ResponseWriter, r *http.Request) {
h.fail(w, r, err)
return
}
attachment, content, err := h.attachments.Open(r.Context(), actor(r), id, r.URL.Query().Get("variant"))
query := r.URL.Query()
variant := query.Get("variant")
if query.Has("variant") && variant == "" {
h.fail(w, r, badRequest("variant must be original"))
return
}
attachment, content, err := h.attachments.Open(r.Context(), actor(r), id, variant)
if err != nil {
h.fail(w, r, err)
return
+3 -2
View File
@@ -1,6 +1,7 @@
package handler
import (
"encoding/json"
"time"
"uuid"
@@ -19,8 +20,8 @@ type createChatRequest struct {
}
type createMessageRequest struct {
Text *string `json:"text"`
AttachmentIDs *[]string `json:"attachment_ids"`
Text *string `json:"text"`
AttachmentIDs json.RawMessage `json:"attachment_ids"`
}
type userResponse struct {
+15 -4
View File
@@ -1,6 +1,8 @@
package handler
import (
"bytes"
"encoding/json"
"net/http"
"regexp"
"uuid"
@@ -31,10 +33,19 @@ func (h *Handler) SendMessage(w http.ResponseWriter, r *http.Request) {
return
}
var attachmentIDs []uuid.UUID
if req.AttachmentIDs != nil {
attachmentIDs = make([]uuid.UUID, len(*req.AttachmentIDs))
for i, raw := range *req.AttachmentIDs {
id, ok := parseUUID(raw)
if len(req.AttachmentIDs) > 0 {
if bytes.Equal(bytes.TrimSpace(req.AttachmentIDs), []byte("null")) {
h.fail(w, r, badRequest("attachment_ids must be an array of UUIDs"))
return
}
var raw []string
if err := json.Unmarshal(req.AttachmentIDs, &raw); err != nil {
h.fail(w, r, badRequest("attachment_ids must be an array of UUIDs"))
return
}
attachmentIDs = make([]uuid.UUID, len(raw))
for i, value := range raw {
id, ok := parseUUID(value)
if !ok {
h.fail(w, r, badRequest("attachment_ids must contain UUIDs"))
return