feat(ECR-029): ContentSafety BlockPolicy 只读并 Closed
BlockPolicy catalog (000030) · Loop continuous.
This commit is contained in:
@@ -38,6 +38,7 @@
|
|||||||
| [ops-scheduled-publication.md](ops-scheduled-publication.md) | OpsCMS ScheduledPublication | §7 | `GET /admin/cms/publications*` | Ops-D · **ECR-026 Closed** |
|
| [ops-scheduled-publication.md](ops-scheduled-publication.md) | OpsCMS ScheduledPublication | §7 | `GET /admin/cms/publications*` | Ops-D · **ECR-026 Closed** |
|
||||||
| [ops-knowledge-chunk.md](ops-knowledge-chunk.md) | AICoreConfig KnowledgeChunk | §7 | `GET /admin/ai/knowledge-chunks*` | Ops-D · **ECR-027 Closed** |
|
| [ops-knowledge-chunk.md](ops-knowledge-chunk.md) | AICoreConfig KnowledgeChunk | §7 | `GET /admin/ai/knowledge-chunks*` | Ops-D · **ECR-027 Closed** |
|
||||||
| [ops-tool-definition.md](ops-tool-definition.md) | AICoreConfig ToolDefinition | §7 | `GET /admin/ai/tools*` | Ops-D · **ECR-028 Closed** |
|
| [ops-tool-definition.md](ops-tool-definition.md) | AICoreConfig ToolDefinition | §7 | `GET /admin/ai/tools*` | Ops-D · **ECR-028 Closed** |
|
||||||
|
| [ops-block-policy.md](ops-block-policy.md) | ContentSafety BlockPolicy | §7 | `GET /admin/content-safety/block-policies*` | Ops-D · **ECR-029 Closed** |
|
||||||
|
|
||||||
新功能:复制 `_TEMPLATE.md` → 填满 → 在本表登记 → 再编码。
|
新功能:复制 `_TEMPLATE.md` → 填满 → 在本表登记 → 再编码。
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
# Feature Spec: ContentSafety · BlockPolicy(Ops · ECR-029)
|
||||||
|
|
||||||
|
> Status: `Active`(Loop continuous · **ECR-029 Closed**)
|
||||||
|
> Parent: WAVE0-FROZEN · Predecessor: ECR-028 Closed
|
||||||
|
> Capability: `ContentSafety` · BC: `Content_Safety`
|
||||||
|
> 授权:`docs/WAVE0/LOOP_AUTHORIZATION.md`
|
||||||
|
|
||||||
|
## Non-goals
|
||||||
|
|
||||||
|
策略写发布 · 用户侧硬拦截上线 · UGC · 真支付
|
||||||
|
|
||||||
|
## L2 Domain
|
||||||
|
|
||||||
|
| 概念 | 语义 |
|
||||||
|
|------|------|
|
||||||
|
| `BlockPolicy` | 本切片只读目录;code 唯一(若适用) |
|
||||||
|
|
||||||
|
## L3 API
|
||||||
|
|
||||||
|
| Method | Path | 权限 | 语义 |
|
||||||
|
|--------|------|------|------|
|
||||||
|
| GET | `/admin/content-safety/block-policies` | `admin.content_safety.read` | 只读 |
|
||||||
|
| GET | `/admin/content-safety/block-policies/{id}` | `admin.content_safety.read` | 只读 |
|
||||||
|
|
||||||
|
## Migration
|
||||||
|
|
||||||
|
`000030`:表 + 种子(若有)(权限复用)
|
||||||
|
|
||||||
|
## L4 AC
|
||||||
|
|
||||||
|
| ID | Then |
|
||||||
|
|----|------|
|
||||||
|
| AC-F-01 | list 含种子或空列表合法 |
|
||||||
|
| AC-F-02 | 已知 id get 200 |
|
||||||
|
| AC-F-03 | 未知 id → 404 |
|
||||||
|
| AC-S-01 | 无 Admin → 401 |
|
||||||
|
| AC-S-02 | 无权限 → 403 |
|
||||||
|
| AC-P-01 | list < 500ms |
|
||||||
|
| AC-O-01 | N/A 只读 |
|
||||||
|
|
||||||
|
contract_diff: `docs/CONTRACT_DIFF/ECR-029.yaml`
|
||||||
@@ -449,6 +449,10 @@ export const adminApi = {
|
|||||||
request<{ items: Array<Record<string, unknown>> }>('GET', '/ai/tools'),
|
request<{ items: Array<Record<string, unknown>> }>('GET', '/ai/tools'),
|
||||||
tool: (id: string) =>
|
tool: (id: string) =>
|
||||||
request<Record<string, unknown>>('GET', `/ai/tools/${id}`),
|
request<Record<string, unknown>>('GET', `/ai/tools/${id}`),
|
||||||
|
blockPolicies: () =>
|
||||||
|
request<{ items: Array<Record<string, unknown>> }>('GET', '/content-safety/block-policies'),
|
||||||
|
blockPolicie: (id: string) =>
|
||||||
|
request<Record<string, unknown>>('GET', `/content-safety/block-policies/${id}`),
|
||||||
orders: () =>
|
orders: () =>
|
||||||
request<{
|
request<{
|
||||||
items: Array<{
|
items: Array<{
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ func (h *AdminHandler) Register(api *gin.RouterGroup) {
|
|||||||
h.registerCMSPublications(authed)
|
h.registerCMSPublications(authed)
|
||||||
h.registerKnowledgeChunks(authed)
|
h.registerKnowledgeChunks(authed)
|
||||||
h.registerToolDefinitions(authed)
|
h.registerToolDefinitions(authed)
|
||||||
|
h.registerBlockPolicies(authed)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *AdminHandler) Login(c *gin.Context) {
|
func (h *AdminHandler) Login(c *gin.Context) {
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package handler
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
|
||||||
|
"github.com/yuxingu/digital-psychology/apps/api/internal/middleware"
|
||||||
|
"github.com/yuxingu/digital-psychology/apps/api/internal/service/admin"
|
||||||
|
"github.com/yuxingu/digital-psychology/apps/api/pkg/response"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (h *AdminHandler) registerBlockPolicies(authed *gin.RouterGroup) {
|
||||||
|
g := authed.Group("/content-safety")
|
||||||
|
g.GET("/block-policies", middleware.RequireAdminPermission(h.Svc, admin.PermContentSafetyRead), h.ListBlockPolicies)
|
||||||
|
g.GET("/block-policies/:id", middleware.RequireAdminPermission(h.Svc, admin.PermContentSafetyRead), h.GetBlockPolicy)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *AdminHandler) ListBlockPolicies(c *gin.Context) {
|
||||||
|
items, err := h.Svc.ListBlockPolicies(c.Request.Context())
|
||||||
|
if err != nil {
|
||||||
|
response.Fail(c, http.StatusInternalServerError, 50050, "list block-policy failed")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OK(c, gin.H{"items": items})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *AdminHandler) GetBlockPolicy(c *gin.Context) {
|
||||||
|
id, err := uuid.Parse(c.Param("id"))
|
||||||
|
if err != nil {
|
||||||
|
response.Fail(c, http.StatusBadRequest, 40002, "invalid id")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
row, err := h.Svc.GetBlockPolicy(c.Request.Context(), id)
|
||||||
|
if errors.Is(err, admin.ErrBlockPolicyNotFound) {
|
||||||
|
response.Fail(c, http.StatusNotFound, 40420, "block-policy not found")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
response.Fail(c, http.StatusInternalServerError, 50051, "get block-policy failed")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.OK(c, row)
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
package integration_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"golang.org/x/crypto/bcrypt"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestContentSafetyBlockPolicies(t *testing.T) {
|
||||||
|
r, pool := setupAPIPool(t)
|
||||||
|
ctx := context.Background()
|
||||||
|
tok := adminLogin(t, r, "admin", "change-me")
|
||||||
|
|
||||||
|
_, code := doAdminJSON(t, r, http.MethodGet, "/api/v1/admin/content-safety/block-policies", nil, "")
|
||||||
|
if code != http.StatusUnauthorized {
|
||||||
|
t.Fatalf("expected 401, got %d", code)
|
||||||
|
}
|
||||||
|
|
||||||
|
limitedRoleID := uuid.New()
|
||||||
|
_, err := pool.Exec(ctx, `INSERT INTO admin_roles(id, name, system) VALUES ($1,$2,false)`,
|
||||||
|
limitedRoleID, "lim_"+limitedRoleID.String()[:8])
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
_, err = pool.Exec(ctx, `INSERT INTO admin_role_permissions(role_id, code) VALUES ($1,'admin.users.read')`, limitedRoleID)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
hash, err := bcrypt.GenerateFromPassword([]byte("limited-pass"), bcrypt.DefaultCost)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
limUser := fmt.Sprintf("lim_%d", time.Now().UnixNano())
|
||||||
|
_, err = pool.Exec(ctx, `INSERT INTO admin_accounts(username, password_hash, role_id) VALUES ($1,$2,$3)`,
|
||||||
|
limUser, string(hash), limitedRoleID)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
t.Cleanup(func() {
|
||||||
|
_, _ = pool.Exec(ctx, `DELETE FROM admin_accounts WHERE username=$1`, limUser)
|
||||||
|
_, _ = pool.Exec(ctx, `DELETE FROM admin_roles WHERE id=$1`, limitedRoleID)
|
||||||
|
})
|
||||||
|
limTok := adminLogin(t, r, limUser, "limited-pass")
|
||||||
|
_, code = doAdminJSON(t, r, http.MethodGet, "/api/v1/admin/content-safety/block-policies", nil, limTok)
|
||||||
|
if code != http.StatusForbidden {
|
||||||
|
t.Fatalf("expected 403, got %d", code)
|
||||||
|
}
|
||||||
|
|
||||||
|
start := time.Now()
|
||||||
|
env, code := doAdminJSON(t, r, http.MethodGet, "/api/v1/admin/content-safety/block-policies", nil, tok)
|
||||||
|
if code != 200 || env.Code != 0 {
|
||||||
|
t.Fatalf("list http=%d msg=%s", code, env.Message)
|
||||||
|
}
|
||||||
|
if time.Since(start) > 500*time.Millisecond {
|
||||||
|
t.Fatalf("list too slow %v", time.Since(start))
|
||||||
|
}
|
||||||
|
var list struct {
|
||||||
|
Items []struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
Code string `json:"code"`
|
||||||
|
} `json:"items"`
|
||||||
|
}
|
||||||
|
_ = json.Unmarshal(env.Data, &list)
|
||||||
|
var id string
|
||||||
|
for _, it := range list.Items {
|
||||||
|
if it.Code == "block_spam_link" {
|
||||||
|
id = it.ID
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if id == "" {
|
||||||
|
t.Fatalf("missing block_spam_link: %#v", list.Items)
|
||||||
|
}
|
||||||
|
env, code = doAdminJSON(t, r, http.MethodGet, "/api/v1/admin/content-safety/block-policies/"+id, nil, tok)
|
||||||
|
if code != 200 {
|
||||||
|
t.Fatalf("get %d", code)
|
||||||
|
}
|
||||||
|
_, code = doAdminJSON(t, r, http.MethodGet, "/api/v1/admin/content-safety/block-policies/"+fakeUUID(), nil, tok)
|
||||||
|
if code != http.StatusNotFound {
|
||||||
|
t.Fatalf("expected 404, got %d", code)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
package repository
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/jackc/pgx/v5"
|
||||||
|
)
|
||||||
|
|
||||||
|
// BlockPolicyRow is BlockPolicy catalog row.
|
||||||
|
type BlockPolicyRow struct {
|
||||||
|
ID uuid.UUID `json:"id"`
|
||||||
|
Code string `json:"code"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
Action string `json:"action"`
|
||||||
|
Active bool `json:"active"`
|
||||||
|
System bool `json:"system"`
|
||||||
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListBlockPolicies returns BlockPolicy catalog.
|
||||||
|
func (r *AdminRepo) ListBlockPolicies(ctx context.Context) ([]BlockPolicyRow, error) {
|
||||||
|
rows, err := r.Pool.Query(ctx, `
|
||||||
|
SELECT id, code, title, action, active, system, updated_at
|
||||||
|
FROM block_policies
|
||||||
|
ORDER BY active DESC, code ASC`)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
var out []BlockPolicyRow
|
||||||
|
for rows.Next() {
|
||||||
|
var row BlockPolicyRow
|
||||||
|
if err := rows.Scan(&row.ID, &row.Code, &row.Title, &row.Action, &row.Active, &row.System, &row.UpdatedAt); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
out = append(out, row)
|
||||||
|
}
|
||||||
|
return out, rows.Err()
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetBlockPolicy loads one by id.
|
||||||
|
func (r *AdminRepo) GetBlockPolicy(ctx context.Context, id uuid.UUID) (*BlockPolicyRow, error) {
|
||||||
|
var row BlockPolicyRow
|
||||||
|
err := r.Pool.QueryRow(ctx, `
|
||||||
|
SELECT id, code, title, action, active, system, updated_at
|
||||||
|
FROM block_policies WHERE id=$1`, id,
|
||||||
|
).Scan(&row.ID, &row.Code, &row.Title, &row.Action, &row.Active, &row.System, &row.UpdatedAt)
|
||||||
|
if errors.Is(err, pgx.ErrNoRows) {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &row, nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package admin
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/jackc/pgx/v5"
|
||||||
|
|
||||||
|
"github.com/yuxingu/digital-psychology/apps/api/internal/repository"
|
||||||
|
)
|
||||||
|
|
||||||
|
var ErrBlockPolicyNotFound = errString("block policy not found")
|
||||||
|
|
||||||
|
// ListBlockPolicies returns catalog.
|
||||||
|
func (s *Service) ListBlockPolicies(ctx context.Context) ([]repository.BlockPolicyRow, error) {
|
||||||
|
items, err := s.Repo.ListBlockPolicies(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if items == nil {
|
||||||
|
items = []repository.BlockPolicyRow{}
|
||||||
|
}
|
||||||
|
return items, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetBlockPolicy loads one.
|
||||||
|
func (s *Service) GetBlockPolicy(ctx context.Context, id uuid.UUID) (*repository.BlockPolicyRow, error) {
|
||||||
|
row, err := s.Repo.GetBlockPolicy(ctx, id)
|
||||||
|
if errors.Is(err, pgx.ErrNoRows) {
|
||||||
|
return nil, ErrBlockPolicyNotFound
|
||||||
|
}
|
||||||
|
return row, err
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
DROP TABLE IF EXISTS block_policies;
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
-- ECR-029 BlockPolicy (read catalog)
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS block_policies (
|
||||||
|
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||||
|
code varchar(64) NOT NULL UNIQUE,
|
||||||
|
title varchar(128) NOT NULL,
|
||||||
|
action varchar(32) NOT NULL CHECK (action IN ('block','mask','review')),
|
||||||
|
active boolean NOT NULL DEFAULT true,
|
||||||
|
system boolean NOT NULL DEFAULT false,
|
||||||
|
created_at timestamptz NOT NULL DEFAULT now(),
|
||||||
|
updated_at timestamptz NOT NULL DEFAULT now()
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_block_policies_active ON block_policies(active);
|
||||||
|
|
||||||
|
INSERT INTO block_policies(code, title, action, active, system)
|
||||||
|
VALUES ('block_spam_link', '外链垃圾拦截策略', 'block', true, true)
|
||||||
|
ON CONFLICT (code) DO NOTHING;
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
# Backend Design: ECR-029 BlockPolicy
|
||||||
|
|
||||||
|
| ID | BD-2026-029 |
|
||||||
|
| Status | Approved |
|
||||||
|
| Coding | Loop authorized |
|
||||||
|
| Level | L2 |
|
||||||
|
| Migration | YES 000030 |
|
||||||
|
|
||||||
|
## Backend Change Boundary
|
||||||
|
|
||||||
|
```text
|
||||||
|
Domain: BlockPolicy (read)
|
||||||
|
App: AdminHandler → admin.Service → AdminRepo
|
||||||
|
API: GET /admin/content-safety/block-policies; GET /admin/content-safety/block-policies/{id}
|
||||||
|
Permission: admin.content_safety.read
|
||||||
|
Migration: 000030
|
||||||
|
```
|
||||||
|
|
||||||
|
## Out of boundary
|
||||||
|
|
||||||
|
策略写发布 · 用户侧硬拦截上线 · UGC · 真支付
|
||||||
|
|
||||||
|
Rollback: down migration + remove routes/UI
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
## 2026-08-08
|
## 2026-08-08
|
||||||
|
|
||||||
|
- **ECR-029 Closed**:ContentSafety BlockPolicy(migration 000030 · admin client · /content-safety/block-policies · 只读)
|
||||||
- **ECR-028 Closed**:AICoreConfig ToolDefinition(migration 000029 · admin client · /ai/tools · 只读)
|
- **ECR-028 Closed**:AICoreConfig ToolDefinition(migration 000029 · admin client · /ai/tools · 只读)
|
||||||
- **ECR-027 Closed**:AICoreConfig KnowledgeChunk(migration 000028 · admin client · /ai/knowledge-chunks · 只读)
|
- **ECR-027 Closed**:AICoreConfig KnowledgeChunk(migration 000028 · admin client · /ai/knowledge-chunks · 只读)
|
||||||
- **ECR-026 Closed**:OpsCMS ScheduledPublication(migration 000027 · admin-h5 client + /cms · 只读)
|
- **ECR-026 Closed**:OpsCMS ScheduledPublication(migration 000027 · admin-h5 client + /cms · 只读)
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# CODE_REVIEW — ECR-029
|
||||||
|
|
||||||
|
**Verdict:** Approve → Closed
|
||||||
|
|
||||||
|
Date: 2026-08-08 · Loop continuous
|
||||||
|
|
||||||
|
- BlockPolicy 只读;无 UGC/真支付
|
||||||
|
- Integration AC mapped · OpenAPI updated
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
ecr: ECR-029
|
||||||
|
capability: ContentSafety
|
||||||
|
bounded_context: Content_Safety
|
||||||
|
parent: WAVE0-FROZEN
|
||||||
|
predecessor: ECR-028
|
||||||
|
change:
|
||||||
|
type: additive
|
||||||
|
breaking_change: false
|
||||||
|
migration_required: true
|
||||||
|
compatibility_notes: >
|
||||||
|
Adds BlockPolicy read catalog. Forbidden: UGC / real payment.
|
||||||
|
|
||||||
|
apis:
|
||||||
|
- method: GET
|
||||||
|
path: /api/v1/admin/content-safety/block-policies
|
||||||
|
change: added
|
||||||
|
- method: GET
|
||||||
|
path: /api/v1/admin/content-safety/block-policies/{id}
|
||||||
|
change: added
|
||||||
|
perms:
|
||||||
|
- code: admin.content_safety.read
|
||||||
|
change: unchanged
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
# ECR-029
|
||||||
|
|
||||||
|
**Title:** ContentSafety · BlockPolicy(只读薄切片)
|
||||||
|
**Status:** **Closed**
|
||||||
|
**Closed:** 2026-08-08(Loop continuous)
|
||||||
|
**Parent:** WAVE0-FROZEN · **Predecessor:** ECR-028 Closed
|
||||||
|
**Change Level:** L2
|
||||||
|
|
||||||
|
## Change
|
||||||
|
|
||||||
|
BlockPolicy 只读 · migration 000030 · admin client · /content-safety/block-policies
|
||||||
|
|
||||||
|
## Linked
|
||||||
|
|
||||||
|
Spec `ops-block-policy.md` · BD-2026-029 · CONTRACT_DIFF/ECR-029.yaml · TEST_REPORT/ECR-029.md
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
# ENGINEERING_SPEC — ECR-029
|
||||||
|
|
||||||
|
1. migration 000030
|
||||||
|
2. AdminRepo/Service/Handler
|
||||||
|
3. OpenAPI + admin-h5
|
||||||
|
4. Integration · Closed
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# HANDOFF — ECR-029 Architect → Engineer
|
||||||
|
|
||||||
|
Loop continuous · Approved + Coding. Migration 000030. Forbidden: UGC/真支付.
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# HANDOFF — ECR-029 Engineer → Reviewer
|
||||||
|
|
||||||
|
TestContentSafetyBlockPolicies PASS · Ready for Closed.
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# PRODUCT_SPEC — ECR-029
|
||||||
|
|
||||||
|
对齐 ops-block-policy.md · Approved · Loop · L2 · BlockPolicy 只读
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
# STATE — ECR-029
|
||||||
|
|
||||||
|
| Status | **Closed** |
|
||||||
|
| Phase | closed |
|
||||||
|
| Spec | ops-block-policy.md |
|
||||||
|
| Updated | 2026-08-08 |
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
id: TASK-029-ECR029
|
||||||
|
ecr: ECR-029
|
||||||
|
title: ContentSafety · BlockPolicy(只读薄切片)
|
||||||
|
role: engineer
|
||||||
|
status: closed
|
||||||
|
change_level: L2
|
||||||
|
parent: WAVE0-FROZEN
|
||||||
|
predecessor: ECR-028
|
||||||
|
acceptance:
|
||||||
|
- Spec AC mapped
|
||||||
|
- BlockPolicy read only
|
||||||
|
- No UGC / payment
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
# TEST_REPORT — ECR-029 BlockPolicy
|
||||||
|
|
||||||
|
Date: 2026-08-08 · Loop continuous · commit: `PENDING`
|
||||||
|
|
||||||
|
## Commands
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd apps/api && go test ./internal/integration/ -run TestContentSafetyBlockPolicies -count=1
|
||||||
|
npm run build:admin
|
||||||
|
python3 scripts/ess-validate.py --phase review --ecr ECR-029
|
||||||
|
python3 scripts/ess-gate-check.py --ecr ECR-029
|
||||||
|
```
|
||||||
|
|
||||||
|
## Results
|
||||||
|
|
||||||
|
| Check | Result |
|
||||||
|
|-------|--------|
|
||||||
|
| TestContentSafetyBlockPolicies | PASS |
|
||||||
|
| build:admin | PASS |
|
||||||
|
| ess-validate review | PASS |
|
||||||
|
| ess-gate-check | PASS |
|
||||||
|
|
||||||
|
## AC
|
||||||
|
|
||||||
|
| ID | Evidence |
|
||||||
|
|----|----------|
|
||||||
|
| AC-F-01 | list seed/empty ok |
|
||||||
|
| AC-F-02 | get 200 |
|
||||||
|
| AC-F-03 | 未知 id → 404 |
|
||||||
|
| AC-S-01 | 401 |
|
||||||
|
| AC-S-02 | 403 |
|
||||||
|
| AC-P-01 | list < 500ms |
|
||||||
|
| AC-O-01 | N/A 只读 |
|
||||||
@@ -33,3 +33,4 @@
|
|||||||
| ECR-026 | OpsCMS · ScheduledPublication | **Closed** | Spec ops-scheduled-publication.md · BD-2026-026 · migration 000027 · TEST_REPORT · CODE_REVIEW · Loop continuous |
|
| ECR-026 | OpsCMS · ScheduledPublication | **Closed** | Spec ops-scheduled-publication.md · BD-2026-026 · migration 000027 · TEST_REPORT · CODE_REVIEW · Loop continuous |
|
||||||
| ECR-027 | AICoreConfig · KnowledgeChunk | **Closed** | Spec ops-knowledge-chunk.md · BD-2026-027 · migration 000028 · TEST_REPORT · CODE_REVIEW · Loop continuous |
|
| ECR-027 | AICoreConfig · KnowledgeChunk | **Closed** | Spec ops-knowledge-chunk.md · BD-2026-027 · migration 000028 · TEST_REPORT · CODE_REVIEW · Loop continuous |
|
||||||
| ECR-028 | AICoreConfig · ToolDefinition | **Closed** | Spec ops-tool-definition.md · BD-2026-028 · migration 000029 · TEST_REPORT · CODE_REVIEW · Loop continuous |
|
| ECR-028 | AICoreConfig · ToolDefinition | **Closed** | Spec ops-tool-definition.md · BD-2026-028 · migration 000029 · TEST_REPORT · CODE_REVIEW · Loop continuous |
|
||||||
|
| ECR-029 | ContentSafety · BlockPolicy | **Closed** | Spec ops-block-policy.md · BD-2026-029 · migration 000030 · TEST_REPORT · CODE_REVIEW · Loop continuous |
|
||||||
|
|||||||
@@ -55,4 +55,4 @@ Human 明文:**直接用 Loop,不用人工确认。**
|
|||||||
|
|
||||||
| Done | Next |
|
| Done | Next |
|
||||||
|------|------|
|
|------|------|
|
||||||
| ECR-013A…028 Closed | **ECR-029** BlockPolicy |
|
| ECR-013A…029 Closed | **ECR-030** ModerationCase |
|
||||||
|
|||||||
@@ -723,6 +723,34 @@ paths:
|
|||||||
'404':
|
'404':
|
||||||
description: Not found
|
description: Not found
|
||||||
|
|
||||||
|
/api/v1/admin/content-safety/block-policies:
|
||||||
|
get:
|
||||||
|
tags: [admin]
|
||||||
|
summary: List BlockPolicy catalog
|
||||||
|
description: Requires admin.content_safety.read
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: OK
|
||||||
|
'401':
|
||||||
|
description: Unauthorized
|
||||||
|
'403':
|
||||||
|
description: Forbidden
|
||||||
|
|
||||||
|
/api/v1/admin/content-safety/block-policies/{id}:
|
||||||
|
get:
|
||||||
|
tags: [admin]
|
||||||
|
summary: Get BlockPolicy
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: id
|
||||||
|
required: true
|
||||||
|
schema: { type: string, format: uuid }
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: OK
|
||||||
|
'404':
|
||||||
|
description: Not found
|
||||||
|
|
||||||
/api/v1/admin/crisis/policies:
|
/api/v1/admin/crisis/policies:
|
||||||
get:
|
get:
|
||||||
tags: [admin]
|
tags: [admin]
|
||||||
|
|||||||
Reference in New Issue
Block a user