droboticflow/internal/api/rework_assignment.go
d-robotics 3b06e35681 ✨ feat: B01 timestamp opinion loop + directed-return rollback switch
- server: timestamp scope in canonicalReviewProblems (identity = source +
  canonical frame, discard-slice/out-of-range/exclusive-end rejections with
  explicit messages, zero duration, dual basis conversion; fixes input
  timeBasis being clobbered by the shared branch) and reviewOpinionKey
  (microsecond frame identity); comment summary gains per-point labels;
  slice-id statistics cover timestamp problems
- rework routing: FANYU_REWORK_RETURN=directed|pool rollback switch applied
  at both decision entries (v5.8 plan + legacy /reviews); directed branch
  already existed (22ca5cd8) with 7-scenario matrix; new pool-branch test
  asserts public-pool restore + admin reassignment channel stays available
- frontend (D5): timestamp option in the F scope menu (three-card navigation
  untouched via opinionCardScopes), timestamp opinion list in the review
  panel with click-to-locate, independent G key jump command wired through
  quality + acceptance workbenches; scope type widened
- tests: 4 new Go tests (canonicalization, 6-case rejection table, per-frame
  uniqueness, pool switch) green; api suite failures identical to baseline
  (65); frontend failures subset of baseline 14, zero new; replica-stack
  live demo: save at 60.05s -> exclusive-end rejected -> formal rejection ->
  directed return to original annotator with labeled timestamp comment
- resolve review-rework-workflow issue 01; interactive rework-side point
  positioning handed to issue 02 (return-baseline view)
2026-10-12 22:27:43 +05:30

56 lines
2.1 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package api
import (
"context"
"droboticflow/internal/domain"
"os"
"strings"
)
// reworkReturnMode 报告正式退回的路由策略(B01 回退开关):
// - "directed"(默认):退回定向归还原标注员(spec §10 行为变更裁定,2026-10-12 用户确认);
// - "pool":回退开关打开(FANYU_REWORK_RETURN=pool),恢复退回公共池的历史行为。
func reworkReturnMode() string {
if strings.EqualFold(strings.TrimSpace(os.Getenv("FANYU_REWORK_RETURN")), "pool") {
return "pool"
}
return "directed"
}
// Resolve before recording a decision: transient lookup failures must not silently
// turn a return-to-author decision into a public-pool assignment.
func (s *server) reworkAuthor(ctx context.Context, item domain.HumanItemRecord) (string, error) {
if item.LatestAuthorUserID == "" || item.ReviewRound+1 > item.MaxReworkRounds {
return "", nil
}
user, err := s.store.GetUser(ctx, item.LatestAuthorUserID)
if err != nil {
return "", err
}
if user == nil || user.OrganizationID != item.OrganizationID || user.Status != domain.UserStatusActive || user.Role != domain.UserRoleAnnotator || user.SupplierID == "" {
return "", nil
}
if item.SupplierID != "" && item.SupplierID != user.SupplierID {
return "", nil
}
supplier, err := s.store.GetSupplier(ctx, user.SupplierID)
if err != nil {
return "", err
}
if supplier == nil || supplier.OrganizationID != item.OrganizationID || !strings.EqualFold(supplier.Status, "active") {
return "", nil
}
members, err := s.annotationMembershipsForUser(ctx, item.OrganizationID, item.ProjectID, user.ID)
if err != nil {
return "", err
}
task := domain.AnnotationTaskRecord{ID: item.LegacyTaskID, ProjectID: item.ProjectID, SupplierID: item.SupplierID, ProcessingScope: item.ProcessingScope, ProcessingProfile: item.ProcessingProfile}
if batch, err := s.store.GetHumanBatch(ctx, item.BatchID); err == nil && batch != nil {
task.SupplierPool = batch.ProcessingProfile == domain.ProcessingProfileRawHuman && domain.IsFanyuV58ThreeRoleHumanLoop(batch.Stages)
}
if !membershipHasRole(members, task, domain.AnnotationRoleAnnotator) {
return "", nil
}
return user.ID, nil
}