✨ Implement Fanyu v5.8 synchronized delivery workflow
This commit is contained in:
parent
7ad7a2511a
commit
6076baa6bb
@ -2,6 +2,8 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import bisect
|
||||
import csv
|
||||
import json
|
||||
import pathlib
|
||||
import re
|
||||
@ -188,6 +190,8 @@ def _camera_collection_id(value: Any) -> str:
|
||||
def _right_video_artifacts(inputs: list[dict[str, Any]]) -> list[dict[str, Any]]:
|
||||
artifacts: list[dict[str, Any]] = []
|
||||
for artifact in inputs:
|
||||
if str(artifact.get("type", "")).strip().lower() != "video":
|
||||
continue
|
||||
port = str(artifact.get("portId") or artifact.get("portName") or "").strip()
|
||||
data = artifact.get("data") if isinstance(artifact.get("data"), dict) else {}
|
||||
transform_chain = data.get("transformChain") if isinstance(data.get("transformChain"), list) else []
|
||||
@ -246,6 +250,149 @@ def _materialize_input_video(
|
||||
return resolved
|
||||
|
||||
|
||||
def _materialize_input_file(artifact: dict[str, Any], output: pathlib.Path, helpers: HelperMap) -> pathlib.Path:
|
||||
materialize = helpers.get("source_path_from_item")
|
||||
if not callable(materialize):
|
||||
raise RuntimeError("synchronized delivery cannot materialize a sidecar file")
|
||||
source_ref = helpers.get("source_ref_from_artifact")
|
||||
source = source_ref(artifact) if callable(source_ref) else artifact.get("source", {})
|
||||
name = str(artifact.get("name") or "sidecar.bin").strip()
|
||||
resolved = pathlib.Path(materialize({"source": source if isinstance(source, dict) else {}, "path": str(artifact.get("path", ""))}, name, output, {}))
|
||||
if not resolved.is_file() or resolved.stat().st_size <= 0:
|
||||
raise RuntimeError(f"synchronized delivery sidecar is unavailable: {name}")
|
||||
return resolved
|
||||
|
||||
|
||||
def _sidecar_artifacts(inputs: list[dict[str, Any]], ports: set[str]) -> list[dict[str, Any]]:
|
||||
return [artifact for artifact in inputs if str(artifact.get("portId") or artifact.get("portName") or "").strip() in ports]
|
||||
|
||||
|
||||
def _matching_sidecar(collection_id: str, candidates: list[dict[str, Any]], marker: str = "") -> dict[str, Any]:
|
||||
filtered = [item for item in candidates if not marker or marker in str(item.get("name") or "").lower()]
|
||||
matches = [item for item in filtered if _camera_collection_id(item) == collection_id]
|
||||
if len(matches) == 1:
|
||||
return matches[0]
|
||||
if len(filtered) == 1:
|
||||
return filtered[0]
|
||||
if not matches:
|
||||
raise RuntimeError(f"no {marker or 'sidecar'} file matches collection {collection_id}")
|
||||
raise RuntimeError(f"multiple {marker or 'sidecar'} files match collection {collection_id}")
|
||||
|
||||
|
||||
def _clean_csv_cell(value: Any) -> str:
|
||||
return str(value or "").strip().strip("\ufeff").strip("\t").strip()
|
||||
|
||||
|
||||
def _read_rows(path: pathlib.Path) -> tuple[list[str], list[list[str]]]:
|
||||
lines = path.read_text(encoding="utf-8-sig").splitlines()
|
||||
if not lines:
|
||||
raise RuntimeError(f"sidecar CSV is empty: {path.name}")
|
||||
delimiter = "," if "," in lines[0] else "\t"
|
||||
parsed = list(csv.reader(lines, delimiter=delimiter))
|
||||
header = [_clean_csv_cell(value) for value in parsed[0]]
|
||||
rows = [[_clean_csv_cell(value) for value in row] for row in parsed[1:] if any(_clean_csv_cell(value) for value in row)]
|
||||
return header, rows
|
||||
|
||||
|
||||
def _read_pts(path: pathlib.Path) -> list[int]:
|
||||
header, rows = _read_rows(path)
|
||||
normalized = {name.lower(): index for index, name in enumerate(header)}
|
||||
if "timestamp_us" not in normalized:
|
||||
raise RuntimeError(f"PTS CSV must contain timestamp_us: {path.name}")
|
||||
column = normalized["timestamp_us"]
|
||||
values: list[int] = []
|
||||
for row in rows:
|
||||
try:
|
||||
value = int(row[column])
|
||||
except (IndexError, ValueError) as exc:
|
||||
raise RuntimeError(f"PTS CSV contains an invalid timestamp_us: {path.name}") from exc
|
||||
if values and value <= values[-1]:
|
||||
raise RuntimeError(f"PTS CSV timestamp_us must be strictly increasing: {path.name}")
|
||||
values.append(value)
|
||||
if not values:
|
||||
raise RuntimeError(f"PTS CSV has no frame timestamps: {path.name}")
|
||||
return values
|
||||
|
||||
|
||||
def _read_imu(path: pathlib.Path) -> list[dict[str, Any]]:
|
||||
header, rows = _read_rows(path)
|
||||
indexes = {name.lower(): index for index, name in enumerate(header)}
|
||||
required = {"timestamp_us", "x", "y", "z", "type"}
|
||||
if not required.issubset(indexes):
|
||||
raise RuntimeError(f"IMU CSV must contain timestamp_us,x,y,z,type: {path.name}")
|
||||
result: list[dict[str, Any]] = []
|
||||
previous = -1
|
||||
for row in rows:
|
||||
try:
|
||||
timestamp = int(row[indexes["timestamp_us"]])
|
||||
kind = row[indexes["type"]].lower()
|
||||
values = [float(row[indexes[key]]) for key in ("x", "y", "z")]
|
||||
except (IndexError, ValueError) as exc:
|
||||
raise RuntimeError(f"IMU CSV contains an invalid row: {path.name}") from exc
|
||||
if kind not in {"accel", "gyro"} or timestamp < previous:
|
||||
raise RuntimeError(f"IMU CSV type/timestamp ordering is invalid: {path.name}")
|
||||
previous = timestamp
|
||||
result.append({"timestamp_us": timestamp, "x": values[0], "y": values[1], "z": values[2], "type": kind})
|
||||
if not result:
|
||||
raise RuntimeError(f"IMU CSV has no samples: {path.name}")
|
||||
return result
|
||||
|
||||
|
||||
def _ffprobe_frame_count(path: pathlib.Path) -> int:
|
||||
completed = subprocess.run(["ffprobe", "-v", "error", "-select_streams", "v:0", "-count_frames", "-show_entries", "stream=nb_read_frames", "-of", "default=nokey=1:noprint_wrappers=1", str(path)], capture_output=True, text=True, check=False)
|
||||
try:
|
||||
count = int(completed.stdout.strip())
|
||||
except ValueError as exc:
|
||||
raise RuntimeError(f"cannot determine decoded video frame count: {path.name}") from exc
|
||||
if completed.returncode != 0 or count <= 0:
|
||||
raise RuntimeError(f"cannot determine decoded video frame count: {path.name}")
|
||||
return count
|
||||
|
||||
|
||||
def _write_frame_segment(source: pathlib.Path, destination: pathlib.Path, start_frame: int, end_frame: int) -> None:
|
||||
if shutil.which("ffmpeg") is None or shutil.which("ffprobe") is None:
|
||||
raise RuntimeError("synchronized delivery requires ffmpeg and ffprobe")
|
||||
if start_frame < 0 or end_frame <= start_frame:
|
||||
raise RuntimeError("synchronized video frame range is empty")
|
||||
destination.parent.mkdir(parents=True, exist_ok=True)
|
||||
expression = f"trim=start_frame={start_frame}:end_frame={end_frame},setpts=PTS-STARTPTS"
|
||||
completed = subprocess.run(["ffmpeg", "-nostdin", "-hide_banner", "-loglevel", "error", "-y", "-i", str(source), "-an", "-vf", expression, "-c:v", "libx264", "-preset", "veryfast", "-crf", "23", "-pix_fmt", "yuv420p", "-movflags", "+faststart", str(destination)], capture_output=True, text=True, check=False)
|
||||
if completed.returncode != 0 or not destination.is_file() or destination.stat().st_size <= 0:
|
||||
raise RuntimeError(f"synchronized frame-accurate cut failed: {(completed.stderr or completed.stdout).strip()[:800]}")
|
||||
|
||||
|
||||
def _write_pts_slice(path: pathlib.Path, timestamps: list[int], start_index: int, end_index: int) -> dict[str, Any]:
|
||||
selected = timestamps[start_index:end_index]
|
||||
if not selected:
|
||||
raise RuntimeError("synchronized PTS slice is empty")
|
||||
with path.open("w", encoding="utf-8", newline="") as handle:
|
||||
writer = csv.writer(handle)
|
||||
writer.writerow(["frame_index", "timestamp_ms", "clip_time_ms"])
|
||||
origin = selected[0]
|
||||
for index, value in enumerate(selected):
|
||||
writer.writerow([index, round(value / 1000), round((value - origin) / 1000)])
|
||||
return {"name": path.name, "sha256": _sha256_file(path), "bytes": path.stat().st_size, "rowCount": len(selected), "firstTimestampUs": selected[0], "lastTimestampUs": selected[-1]}
|
||||
|
||||
|
||||
def _write_imu_slice(path: pathlib.Path, rows: list[dict[str, Any]], start_us: int, end_us: int) -> dict[str, Any]:
|
||||
selected = [row for row in rows if start_us <= int(row["timestamp_us"]) < end_us]
|
||||
if not selected:
|
||||
raise RuntimeError("synchronized IMU slice is empty")
|
||||
by_timestamp: dict[int, set[str]] = {}
|
||||
for row in selected:
|
||||
by_timestamp.setdefault(int(row["timestamp_us"]), set()).add(str(row["type"]))
|
||||
if any(types != {"accel", "gyro"} for types in by_timestamp.values()):
|
||||
raise RuntimeError("synchronized IMU slice contains an unpaired accel/gyro timestamp")
|
||||
with path.open("w", encoding="utf-8", newline="") as handle:
|
||||
writer = csv.writer(handle)
|
||||
writer.writerow(["timestamp_ms", "clip_time_ms", "x", "y", "z", "type"])
|
||||
origin = int(selected[0]["timestamp_us"])
|
||||
for row in selected:
|
||||
timestamp = int(row["timestamp_us"])
|
||||
writer.writerow([round(timestamp / 1000), round((timestamp - origin) / 1000), row["x"], row["y"], row["z"], row["type"]])
|
||||
return {"name": path.name, "sha256": _sha256_file(path), "bytes": path.stat().st_size, "sampleCount": len(selected), "timestampCount": len(by_timestamp), "firstTimestampUs": int(selected[0]["timestamp_us"]), "lastTimestampUs": int(selected[-1]["timestamp_us"])}
|
||||
|
||||
|
||||
def _write_verified_segment(
|
||||
source: pathlib.Path,
|
||||
destination: pathlib.Path,
|
||||
@ -269,7 +416,7 @@ def _write_verified_segment(
|
||||
}
|
||||
|
||||
|
||||
def _validate_final_acceptance(item: dict[str, Any]) -> None:
|
||||
def _validate_final_acceptance(item: dict[str, Any]) -> dict[str, Any]:
|
||||
evidence = item.get("finalAcceptance") if isinstance(item.get("finalAcceptance"), dict) else {}
|
||||
canonical = str(evidence.get("canonical", ""))
|
||||
digest = str(evidence.get("sha256", "")).lower()
|
||||
@ -279,6 +426,7 @@ def _validate_final_acceptance(item: dict[str, Any]) -> None:
|
||||
raise RuntimeError("pre-package acceptance evidence SHA-256 does not verify")
|
||||
if not str(evidence.get("confirmedByUserId", "")).strip():
|
||||
raise RuntimeError("pre-package acceptance evidence has no confirmer identity")
|
||||
return evidence
|
||||
|
||||
|
||||
def _write_precise_final_segment(source: pathlib.Path, destination: pathlib.Path, start: float, end: float) -> None:
|
||||
@ -357,6 +505,23 @@ def _materialize_final_mp4(item: dict[str, Any], package_dir: pathlib.Path, help
|
||||
return destination
|
||||
|
||||
|
||||
def _materialize_left_source(item: dict[str, Any], directory: pathlib.Path, helpers: HelperMap) -> pathlib.Path:
|
||||
source_path = pathlib.Path(str(item.get("clipPath", "")).strip())
|
||||
if source_path.is_file() and source_path.stat().st_size > 0:
|
||||
return source_path
|
||||
source = item.get("source") if isinstance(item.get("source"), dict) else {}
|
||||
resolved = pathlib.Path(
|
||||
helpers["source_path_from_item"](
|
||||
{"source": source or {"path": str(item.get("clipPath", "")).strip()}},
|
||||
str(item.get("sourceVideo") or pathlib.PurePosixPath(str(item.get("clipPath", ""))).name or "left-camera.mp4"),
|
||||
directory,
|
||||
)
|
||||
)
|
||||
if not resolved.is_file() or resolved.stat().st_size <= 0:
|
||||
raise RuntimeError("left-camera video is unavailable for synchronized cropping")
|
||||
return resolved
|
||||
|
||||
|
||||
def _collect_unique_package_artifacts(
|
||||
run_id: str,
|
||||
node_id: str,
|
||||
@ -382,6 +547,90 @@ def _collect_unique_package_artifacts(
|
||||
return artifacts
|
||||
|
||||
|
||||
def _copy_calibrations(inputs: list[dict[str, Any]], packages_root: pathlib.Path, output: pathlib.Path, helpers: HelperMap) -> list[dict[str, Any]]:
|
||||
destination = packages_root / "calibration"
|
||||
result: list[dict[str, Any]] = []
|
||||
seen: set[str] = set()
|
||||
for artifact in _sidecar_artifacts(inputs, {"calibrations"}):
|
||||
name = str(artifact.get("name") or "").strip()
|
||||
if not name or name in seen:
|
||||
continue
|
||||
seen.add(name)
|
||||
source = _materialize_input_file(artifact, output / "_inputs", helpers)
|
||||
destination.mkdir(parents=True, exist_ok=True)
|
||||
target = destination / name
|
||||
shutil.copy2(source, target)
|
||||
result.append({"name": name, "path": f"calibration/{name}", "sha256": _sha256_file(target), "bytes": target.stat().st_size})
|
||||
if not result:
|
||||
raise RuntimeError("synchronized delivery requires camera/IMU calibration files")
|
||||
return result
|
||||
|
||||
|
||||
def _synchronized_segment(
|
||||
item: dict[str, Any],
|
||||
clip_id: str,
|
||||
package_dir: pathlib.Path,
|
||||
output: pathlib.Path,
|
||||
start: float,
|
||||
end: float,
|
||||
inputs: list[dict[str, Any]],
|
||||
right_videos: list[dict[str, Any]],
|
||||
helpers: HelperMap,
|
||||
) -> tuple[pathlib.Path, dict[str, Any], dict[str, Any]]:
|
||||
collection_id = str(item.get("collectionId") or "").strip() or _camera_collection_id(_source_video_name(item))
|
||||
left_pts_artifact = _matching_sidecar(collection_id, _sidecar_artifacts(inputs, {"leftTimestamps"}), "left")
|
||||
right_pts_artifact = _matching_sidecar(collection_id, _sidecar_artifacts(inputs, {"rightTimestamps"}), "right")
|
||||
imu_artifact = _matching_sidecar(collection_id, _sidecar_artifacts(inputs, {"imu"}), "imu")
|
||||
left_pts_path = _materialize_input_file(left_pts_artifact, output / "_inputs", helpers)
|
||||
right_pts_path = _materialize_input_file(right_pts_artifact, output / "_inputs", helpers)
|
||||
imu_path = _materialize_input_file(imu_artifact, output / "_inputs", helpers)
|
||||
left_pts = _read_pts(left_pts_path)
|
||||
right_pts = _read_pts(right_pts_path)
|
||||
imu_rows = _read_imu(imu_path)
|
||||
left_source = _materialize_left_source(item, output / "_inputs", helpers)
|
||||
right_artifact = _matching_right_video(item, right_videos)
|
||||
if right_artifact is None:
|
||||
raise RuntimeError(f"accepted segment {clip_id} has no matching right-camera video")
|
||||
right_source = _materialize_input_video(right_artifact, output / "_inputs", helpers)
|
||||
if _ffprobe_frame_count(left_source) != len(left_pts):
|
||||
raise RuntimeError("left-camera decoded frame count does not match left PTS rows")
|
||||
if _ffprobe_frame_count(right_source) != len(right_pts):
|
||||
raise RuntimeError("right-camera decoded frame count does not match right PTS rows")
|
||||
target_start_us = left_pts[0] + round(start * 1_000_000)
|
||||
target_end_us = left_pts[0] + round(end * 1_000_000)
|
||||
imu_first, imu_last = int(imu_rows[0]["timestamp_us"]), int(imu_rows[-1]["timestamp_us"])
|
||||
common_start = max(left_pts[0], right_pts[0], imu_first)
|
||||
common_end = min(left_pts[-1], right_pts[-1], imu_last)
|
||||
if target_start_us < common_start or target_end_us > common_end or target_end_us <= target_start_us:
|
||||
raise RuntimeError("final segment is outside the common left/right/IMU hardware timestamp range")
|
||||
left_start, left_end = bisect.bisect_left(left_pts, target_start_us), bisect.bisect_left(left_pts, target_end_us)
|
||||
right_start, right_end = bisect.bisect_left(right_pts, target_start_us), bisect.bisect_left(right_pts, target_end_us)
|
||||
left_destination = package_dir / str(item.get("clipName") or f"{clip_id}_left.mp4")
|
||||
right_destination = package_dir / f"{clip_id}_right.mp4"
|
||||
_write_frame_segment(left_source, left_destination, left_start, left_end)
|
||||
_write_frame_segment(right_source, right_destination, right_start, right_end)
|
||||
if _ffprobe_frame_count(left_destination) != left_end - left_start or _ffprobe_frame_count(right_destination) != right_end - right_start:
|
||||
raise RuntimeError("synchronized output frame count does not match sliced PTS rows")
|
||||
left_pts_manifest = _write_pts_slice(package_dir / f"{clip_id}_left_pts.csv", left_pts, left_start, left_end)
|
||||
right_pts_manifest = _write_pts_slice(package_dir / f"{clip_id}_right_pts.csv", right_pts, right_start, right_end)
|
||||
imu_manifest = _write_imu_slice(package_dir / f"{clip_id}_imu.csv", imu_rows, target_start_us, target_end_us)
|
||||
left_video = {"name": left_destination.name, "sha256": _sha256_file(left_destination), "bytes": left_destination.stat().st_size, "cameraSide": "left", "frameCount": left_end - left_start}
|
||||
right_video = {"name": right_destination.name, "sha256": _sha256_file(right_destination), "bytes": right_destination.stat().st_size, "cameraSide": "right", "frameCount": right_end - right_start, "sourceVideo": str(right_artifact.get("name") or right_source.name)}
|
||||
alignment_values = [left_pts[left_start], right_pts[right_start], int(imu_manifest["firstTimestampUs"]), left_pts[left_end - 1], right_pts[right_end - 1], int(imu_manifest["lastTimestampUs"])]
|
||||
max_alignment_error_us = max(abs(value - target_start_us) for value in alignment_values[:3])
|
||||
synchronized = {
|
||||
"schemaVersion": "droboticflow.synchronized-slice/v1",
|
||||
"collectionId": collection_id,
|
||||
"window": {"startTimestampUs": target_start_us, "endTimestampUs": target_end_us, "semantics": "half-open"},
|
||||
"commonRange": {"startTimestampUs": common_start, "endTimestampUs": common_end},
|
||||
"left": {"video": left_video, "pts": left_pts_manifest},
|
||||
"right": {"video": right_video, "pts": right_pts_manifest},
|
||||
"imu": imu_manifest,
|
||||
"maxStartAlignmentErrorUs": max_alignment_error_us,
|
||||
}
|
||||
return left_destination, right_video, synchronized
|
||||
|
||||
|
||||
def _run_fanyu_v5(run_id: str, node_id: str, output_dir: Any, node_data: dict[str, Any], inputs: list[dict[str, Any]], helpers: HelperMap) -> list[dict[str, Any]]:
|
||||
output = pathlib.Path(output_dir)
|
||||
output.mkdir(parents=True, exist_ok=True)
|
||||
@ -392,14 +641,16 @@ def _run_fanyu_v5(run_id: str, node_id: str, output_dir: Any, node_data: dict[st
|
||||
pose_free = _bool(params, "POSE_FREE", False)
|
||||
require_final_acceptance = _bool(params, "REQUIRE_FINAL_ACCEPTANCE", False)
|
||||
generate_segment_mp4 = _bool(params, "GENERATE_SEGMENT_MP4", False)
|
||||
synchronized_sidecars = _bool(params, "SYNCHRONIZED_SIDECARS", False)
|
||||
allow_pose_exclusion = _bool(params, "ALLOW_POSE_EXCLUSION", False)
|
||||
payloads = _payload_tree(_payloads_with_full_pose_manifests(inputs, output, helpers))
|
||||
headpose = _first_payload(payloads, "droboticflow.headpose/v1")
|
||||
handpose = _first_payload(payloads, "droboticflow.wilor.hand_pose_result/v1")
|
||||
if pose_free and (headpose is not None or handpose is not None):
|
||||
raise RuntimeError("pose-free v5 package rejects HeadPose and HandPose payloads")
|
||||
if require_headpose and (headpose is None or not headpose.get("enabled") or not isinstance(headpose.get("frames"), list)):
|
||||
if require_headpose and not allow_pose_exclusion and (headpose is None or not headpose.get("enabled") or not isinstance(headpose.get("frames"), list)):
|
||||
raise RuntimeError("package requires a real Headpose manifest with frames")
|
||||
if require_handpose and (
|
||||
if require_handpose and not allow_pose_exclusion and (
|
||||
handpose is None
|
||||
or handpose.get("enabled") is False
|
||||
or not _pose_frames(handpose, "handpose")
|
||||
@ -427,9 +678,22 @@ def _run_fanyu_v5(run_id: str, node_id: str, output_dir: Any, node_data: dict[st
|
||||
raise RuntimeError("stereo delivery has no accepted Qwen clip with a camera collection")
|
||||
package_items: list[dict[str, Any]] = []
|
||||
binding = helpers["output_binding"](node_data)
|
||||
calibration_refs = _copy_calibrations(inputs, output / "packages", output, helpers) if synchronized_sidecars else []
|
||||
package_pose_policy: dict[str, Any] | None = None
|
||||
for index, item in enumerate(accepted_items):
|
||||
acceptance_evidence: dict[str, Any] = {}
|
||||
if require_final_acceptance:
|
||||
_validate_final_acceptance(item)
|
||||
acceptance_evidence = _validate_final_acceptance(item)
|
||||
pose_policy = acceptance_evidence.get("poseDelivery") if isinstance(acceptance_evidence.get("poseDelivery"), dict) else {}
|
||||
if allow_pose_exclusion:
|
||||
if pose_policy.get("headpose") not in {"include", "exclude"} or pose_policy.get("handpose") not in {"include", "exclude"}:
|
||||
raise RuntimeError("v5.8 final acceptance must decide HeadPose and HandPose inclusion")
|
||||
if package_pose_policy is None:
|
||||
package_pose_policy = pose_policy
|
||||
elif package_pose_policy != pose_policy:
|
||||
raise RuntimeError("v5.8 package items contain conflicting aggregate pose delivery decisions")
|
||||
include_headpose = not allow_pose_exclusion or pose_policy.get("headpose") == "include"
|
||||
include_handpose = not allow_pose_exclusion or pose_policy.get("handpose") == "include"
|
||||
clip_id = str(item.get("clipId") or f"segment-{index + 1:04d}").strip()
|
||||
package_dir = output / "packages" / f"{clip_id}_package"
|
||||
package_dir.mkdir(parents=True, exist_ok=True)
|
||||
@ -439,7 +703,11 @@ def _run_fanyu_v5(run_id: str, node_id: str, output_dir: Any, node_data: dict[st
|
||||
raise RuntimeError("accepted package item has invalid final source boundaries")
|
||||
# 虚拟切片条目没有物理中间片段:无论是否显式要求 MP4,
|
||||
# 都必须按源视频区间在打包阶段精确物化最终交付 MP4。
|
||||
if generate_segment_mp4 or item.get("finalSegment") is True or item.get("virtualCut") is True:
|
||||
synchronized_manifest = None
|
||||
right_video_manifest = None
|
||||
if synchronized_sidecars:
|
||||
video_path, right_video_manifest, synchronized_manifest = _synchronized_segment(item, clip_id, package_dir, output, start, end, inputs, right_videos, helpers)
|
||||
elif generate_segment_mp4 or item.get("finalSegment") is True or item.get("virtualCut") is True:
|
||||
video_path = _materialize_final_mp4(item, package_dir, helpers)
|
||||
else:
|
||||
source = pathlib.Path(str(item.get("clipPath", "")).strip())
|
||||
@ -448,15 +716,14 @@ def _run_fanyu_v5(run_id: str, node_id: str, output_dir: Any, node_data: dict[st
|
||||
video_path = package_dir / (str(item.get("clipName") or source.name))
|
||||
shutil.copy2(source, video_path)
|
||||
annotation = item.get("annotation") if isinstance(item.get("annotation"), dict) else {}
|
||||
headpose_segment = _crop_pose(headpose, start, end, "headpose") if headpose else None
|
||||
handpose_segment = _crop_pose(handpose, start, end, "handpose") if handpose and handpose.get("enabled", True) else None
|
||||
if require_headpose and (headpose_segment is None or headpose_segment["frameCount"] <= 0):
|
||||
headpose_segment = _crop_pose(headpose, start, end, "headpose") if include_headpose and headpose else None
|
||||
handpose_segment = _crop_pose(handpose, start, end, "handpose") if include_handpose and handpose and handpose.get("enabled", True) else None
|
||||
if require_headpose and include_headpose and (headpose_segment is None or headpose_segment["frameCount"] <= 0):
|
||||
raise RuntimeError("required Headpose has no frame inside the final half-open segment interval")
|
||||
if require_handpose and (handpose_segment is None or handpose_segment["frameCount"] <= 0):
|
||||
if require_handpose and include_handpose and (handpose_segment is None or handpose_segment["frameCount"] <= 0):
|
||||
raise RuntimeError("required HandPose has no frame inside the final half-open segment interval")
|
||||
right_video = _matching_right_video(item, right_videos)
|
||||
right_video_manifest = None
|
||||
if right_video is not None:
|
||||
right_video = None if synchronized_sidecars else _matching_right_video(item, right_videos)
|
||||
if not synchronized_sidecars and right_video is not None:
|
||||
right_source = _materialize_input_video(right_video, output, helpers)
|
||||
right_destination = package_dir / f"{clip_id}_right.mp4"
|
||||
right_video_manifest = _write_verified_segment(right_source, right_destination, start, end, helpers)
|
||||
@ -466,9 +733,12 @@ def _run_fanyu_v5(run_id: str, node_id: str, output_dir: Any, node_data: dict[st
|
||||
right_video_manifest["transformChain"] = (
|
||||
right_data.get("transformChain") if isinstance(right_data.get("transformChain"), list) else []
|
||||
)
|
||||
elif require_stereo_delivery:
|
||||
elif not synchronized_sidecars and require_stereo_delivery:
|
||||
raise RuntimeError(f"accepted segment {clip_id} has no matching right-camera video")
|
||||
helpers["write_json_artifact"](run_id, node_id, package_dir, "semantic.json", annotation, output=binding)
|
||||
if synchronized_manifest is not None:
|
||||
synchronized_manifest["calibration"] = calibration_refs
|
||||
helpers["write_json_artifact"](run_id, node_id, package_dir, "synchronized-slice.json", synchronized_manifest, output=binding)
|
||||
segment_manifest = {
|
||||
"schemaVersion": "droboticflow.delivery.segment/v2",
|
||||
"clipId": clip_id,
|
||||
@ -478,6 +748,9 @@ def _run_fanyu_v5(run_id: str, node_id: str, output_dir: Any, node_data: dict[st
|
||||
"semantic": {"file": "semantic.json", "actionCount": len(annotation.get("actions", []))},
|
||||
"transformChain": item.get("transformChain", []) if isinstance(item.get("transformChain"), list) else [],
|
||||
"finalAcceptance": item.get("finalAcceptance") if require_final_acceptance else None,
|
||||
"poseDelivery": pose_policy if allow_pose_exclusion else None,
|
||||
"synchronizedSlice": {"file": "synchronized-slice.json", "schemaVersion": "droboticflow.synchronized-slice/v1"} if synchronized_manifest is not None else None,
|
||||
"calibration": calibration_refs,
|
||||
}
|
||||
segment_manifest["videos"] = {
|
||||
"left": {**segment_manifest["video"], "cameraSide": "left"},
|
||||
@ -495,7 +768,7 @@ def _run_fanyu_v5(run_id: str, node_id: str, output_dir: Any, node_data: dict[st
|
||||
package_items.append({"packageName": package_dir.name, "clipId": clip_id, "clipName": video_path.name, "rightClipName": right_video_manifest["name"] if right_video_manifest else "", "sourceVideo": source_video, "sourceRightVideo": right_video_manifest["sourceVideo"] if right_video_manifest else "", "stereo": right_video_manifest is not None, "storagePath": str(package_dir), "startSecond": start, "endSecond": end, "clipDuration": end - start, "duration": end - start, "fileCount": len([path for path in package_dir.iterdir() if path.is_file()]), "quality": quality, "annotation": annotation, "segmentManifest": segment_manifest})
|
||||
if not package_items:
|
||||
raise RuntimeError("package produced zero final segment packages")
|
||||
manifest = {"schemaVersion": "droboticflow.delivery.manifest/v3", "datasetType": "fanyu-v5-final-segments", "packageCount": len(package_items), "stereoDelivery": all(item["stereo"] for item in package_items), "headposeIncluded": headpose is not None, "handposeIncluded": handpose is not None and handpose.get("enabled", True), "items": package_items, "trainingEnabled": False}
|
||||
manifest = {"schemaVersion": "droboticflow.delivery.manifest/v4" if synchronized_sidecars else "droboticflow.delivery.manifest/v3", "datasetType": "fanyu-v5-final-segments", "packageCount": len(package_items), "stereoDelivery": all(item["stereo"] for item in package_items), "headposeIncluded": headpose is not None and (not allow_pose_exclusion or (package_pose_policy or {}).get("headpose") == "include"), "handposeIncluded": handpose is not None and handpose.get("enabled", True) and (not allow_pose_exclusion or (package_pose_policy or {}).get("handpose") == "include"), "poseDelivery": package_pose_policy, "audioIncluded": False if synchronized_sidecars else None, "calibration": calibration_refs, "items": package_items, "trainingEnabled": False}
|
||||
artifacts = [helpers["write_json_artifact"](run_id, node_id, output, "packages-manifest.json", manifest, output=binding)]
|
||||
artifacts.extend(_collect_unique_package_artifacts(run_id, node_id, output / "packages", node_data, binding, helpers))
|
||||
return artifacts
|
||||
|
||||
@ -2,12 +2,12 @@
|
||||
|
||||
> 插件化重构后的通用状态机、API、分区释放和深链约定见 [Human Loop Core 与 Annotation QA 插件](./human-loop-plugin.md)。本页保留 Annotation QA 领域对象和兼容接口说明。
|
||||
|
||||
`/annotation-operations` 提供项目级语义模板、供应商分组、逐段标注、审核、验收、返工和工时统计。平台全局角色负责登录后的工作台边界,项目成员关系进一步限定项目、供应商和工作组。生产角色固定为三类:
|
||||
`/annotation-operations` 提供项目级语义模板、供应商分组、真实切分、逐段标注、审核、验收、返工和工时统计。平台全局角色负责登录后的工作台边界,项目成员关系进一步限定项目、供应商和工作组。v5.8 生产角色固定为三类:
|
||||
|
||||
- `cutter`(人工剪切员):从剪切池领取自动粗切结果,调整边界、拆分、合并或重做切片。
|
||||
- `annotator`(标注员):从剪切审核池和语义标注池领取任务;剪切不可用时打回人工剪切池,可用时继续领取同一片段的语义标注任务。
|
||||
- `quality_reviewer`(审核员):从标注审核池和最终验收池领取任务;同一审核角色负责逐片段标注质量结论和聚合包前/成品包最终验收。
|
||||
- `acceptance_reviewer`:仅保留为历史兼容角色,权限按 `quality_reviewer` 解释,不再作为新流程的独立岗位。
|
||||
- `annotator`(标注员):在同一个原子提交中完成真实切分校正和语义标注;既可先切完再标,也可边切边标。
|
||||
- `quality_reviewer`(审核员):独立审核切分边界、左右目对应关系和语义标注,拒绝时把整条源任务退回标注员。
|
||||
- `acceptance_reviewer`(最终验收员):在自动打包前独立执行整包全量验收;拒绝时整包退回审核员,不得参与该批次标注审核。
|
||||
- `cutter`:只保留历史 v5.7 任务兼容,新建 v5.8 项目不再分配该角色。
|
||||
- `vendor_manager`:只聚合查看所管供应商/工作组的工作量和质量,不能读取任务媒体或执行审核。
|
||||
|
||||
每个成员关系同时绑定 `projectId`、`workgroupId` 和 `vendorId`。除管理员、流程工程师和兼容管理员外,后端只返回当前用户所在分组的任务、模板、分组和工时事件;前端隐藏不是安全边界。
|
||||
@ -41,7 +41,11 @@
|
||||
- `ANNOTATION_WORKGROUP_ID`:目标供应商分组。
|
||||
- 新任务不接受 `ANNOTATION_ASSIGNED_USER_ID` 预分配;成员从 HumanItem 待领取池主动领取。
|
||||
|
||||
Worker 到达该节点后不会启动 Kubernetes Job,也不会创建通用 AuditTask。它会从上游 `clips-manifest.json`、视频 artifact 和预标 JSON 自动按片段创建 AnnotationTask,并写入 `projectId`、`dataTaskId`、`workflowId`、`runId`、`nodeId`、`artifactId`。Run 保持 `waiting_for_audit`,直到该节点下所有任务依次完成:人工剪切员调整切片 → 标注员审核剪切 → 标注员语义标注 → 审核员标注审核。审核员随后领取聚合包前或成品包最终验收任务。
|
||||
Worker 到达该节点后不会启动 Kubernetes Job,也不会创建通用 AuditTask。它会从上游真实视频与 Qwen 边界创建 AnnotationTask,并写入 `projectId`、`dataTaskId`、`workflowId`、`runId`、`nodeId`、`artifactId`。Run 保持 `waiting_for_audit`,直到该节点下所有任务依次完成:标注员真实切分与语义标注 → 审核员统一审核 → 最终验收员整包验收。验收通过后系统自动释放 Package child Run。
|
||||
|
||||
v5.8 不预先把长视频拆成多个人工 Task;同一个源任务可提交多个最终切片。无法局部调整的丢帧、流缺失或时间轴异常必须整条任务退回自动重处理,不允许用 FFmpeg 拼接近似修复。
|
||||
|
||||
v5.8 打包以绝对 `timestamp_us` 为权威时钟,按同一个半开窗口同步裁切左右视频、左右 PTS CSV 和 IMU accel/gyro;输出侧车统一为毫秒并保留 clip-relative 时间。Audio 与 audio PTS 不处理、不交付,camera/IMU calibration 原文件在批次根目录保留且不做内参差异管理。
|
||||
|
||||
标注审核通过后,Worker 生成 `droboticflow.annotation.accepted/v1` 的 `annotations-manifest.json`,记录模板版本、人工 revision、片段、artifact 和 Run lineage,然后从节点 `approved` 输出创建分区子 Run。成品打包完成后创建未分配的 Acceptance HumanItem;审核员领取并通过后才记录幂等最终导出快照,拒绝则进入拒绝区。
|
||||
|
||||
|
||||
23
docs/fanyu-v5-8-workflow.md
Normal file
23
docs/fanyu-v5-8-workflow.md
Normal file
@ -0,0 +1,23 @@
|
||||
# 泛宇双目/PTS/IMU 同步切分交付 v5.8
|
||||
|
||||
v5.8 是 v5.7 的不可变后继版本。历史 v5.7 Run 和产物继续可读,新项目默认采用以下流程:
|
||||
|
||||
`目录读取 → 双目标准化 → 双目去畸变 → 双目人脸脱敏 → Qwen 粗切 → 标注员真实切分与语义标注 → 审核员统一审核 → 最终验收员整包验收 → 自动打包`
|
||||
|
||||
## 人工契约
|
||||
|
||||
- 标注员在一个任务中原子提交最终切分与语义标签。
|
||||
- 审核员审核切分、左右目关系和语义;拒绝时整条任务回到合并标注环节。
|
||||
- 最终验收员独立完成整包全量验收;拒绝时所有条目回到审核池。
|
||||
- 验收员分别决定 HeadPose、HandPose 是 `include` 还是 `exclude`;排除 Pose 不阻断基础数据交付。
|
||||
|
||||
## 同步切分契约
|
||||
|
||||
- 不预拆长视频 Task,一个源任务可产生多个最终片段。
|
||||
- 左右视频、左右 PTS、IMU 以绝对硬件微秒时钟求共同有效区间。
|
||||
- 每个片段使用 `[start_us, end_us)`;左右视频按帧号重新编码,PTS 行数必须等于输出解码帧数。
|
||||
- IMU 仅保留窗口内成对 accel/gyro 数据。
|
||||
- 输出 PTS 为 `frame_index,timestamp_ms,clip_time_ms`,IMU 为 `timestamp_ms,clip_time_ms,x,y,z,type`。
|
||||
- Audio/audio PTS 不处理、不交付;calibration 原样保留一份,不做去畸变内参差异管理。
|
||||
|
||||
每个片段生成 `droboticflow.synchronized-slice/v1`,记录窗口、左右帧数、PTS、IMU 样本、最大对齐误差、SHA 和 calibration 引用。任一必需流缺失、时间戳乱序、IMU 不成对或覆盖不足时 fail-closed。
|
||||
@ -101,9 +101,7 @@ func membershipAllowsTaskRead(memberships []domain.ProjectAnnotationMembershipRe
|
||||
|
||||
func membershipHasRole(memberships []domain.ProjectAnnotationMembershipRecord, task domain.AnnotationTaskRecord, role domain.AnnotationAssignmentRole) bool {
|
||||
for _, membership := range memberships {
|
||||
compatible := membership.AssignmentRole == role ||
|
||||
(role == domain.AnnotationRoleQualityReviewer && membership.AssignmentRole == domain.AnnotationRoleAcceptanceReviewer) ||
|
||||
(role == domain.AnnotationRoleAcceptanceReviewer && membership.AssignmentRole == domain.AnnotationRoleQualityReviewer)
|
||||
compatible := membership.AssignmentRole == role
|
||||
if compatible && membershipAllowsTask([]domain.ProjectAnnotationMembershipRecord{membership}, task) {
|
||||
return true
|
||||
}
|
||||
|
||||
@ -91,14 +91,32 @@ func TestAnnotationProductionRolesMatchTheThreePoolModel(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestQualityReviewerMembershipAlsoCoversLegacyAcceptanceRole(t *testing.T) {
|
||||
func TestQualityReviewerMembershipDoesNotCoverIndependentAcceptanceRole(t *testing.T) {
|
||||
task := domain.AnnotationTaskRecord{ProjectID: "project-a", WorkgroupID: "group-a", VendorID: "vendor-a"}
|
||||
memberships := []domain.ProjectAnnotationMembershipRecord{{
|
||||
ProjectID: task.ProjectID, WorkgroupID: task.WorkgroupID, VendorID: task.VendorID,
|
||||
AssignmentRole: domain.AnnotationRoleQualityReviewer,
|
||||
}}
|
||||
if membershipHasRole(memberships, task, domain.AnnotationRoleAcceptanceReviewer) {
|
||||
t.Fatal("quality reviewer must not cover independent final-acceptance membership checks")
|
||||
}
|
||||
memberships = append(memberships, domain.ProjectAnnotationMembershipRecord{ProjectID: task.ProjectID, WorkgroupID: task.WorkgroupID, VendorID: task.VendorID, AssignmentRole: domain.AnnotationRoleAcceptanceReviewer})
|
||||
if !membershipHasRole(memberships, task, domain.AnnotationRoleAcceptanceReviewer) {
|
||||
t.Fatal("quality reviewer must cover legacy final-acceptance membership checks")
|
||||
t.Fatal("explicit acceptance reviewer membership must grant final acceptance")
|
||||
}
|
||||
}
|
||||
|
||||
func TestFanyuV58UsesCombinedAnnotationAndIndependentReview(t *testing.T) {
|
||||
stages := domain.DefaultFanyuV58HumanStages()
|
||||
if !domain.IsFanyuV58ThreeRoleHumanLoop(stages) {
|
||||
t.Fatalf("unexpected v5.8 stages: %#v", stages)
|
||||
}
|
||||
if annotationRoleForHumanStage(stages[0]) != domain.AnnotationRoleAnnotator || annotationRoleForHumanStage(stages[1]) != domain.AnnotationRoleQualityReviewer {
|
||||
t.Fatalf("unexpected v5.8 stage role routing: %#v", stages)
|
||||
}
|
||||
acceptance := domain.HumanStageDefinition{ID: fanyuV5PrePackageAcceptanceStageID, Kind: domain.HumanStageAcceptance, RequiredRole: "acceptance_reviewer"}
|
||||
if annotationRoleForHumanStage(acceptance) != domain.AnnotationRoleAcceptanceReviewer {
|
||||
t.Fatal("v5.8 aggregate acceptance must require an independent acceptance reviewer")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -7710,6 +7710,18 @@
|
||||
"key": "GENERATE_SEGMENT_MP4",
|
||||
"type": "boolean",
|
||||
"value": "false"
|
||||
},
|
||||
{
|
||||
"description": "是否按绝对硬件时间窗口同步裁切左右视频、PTS 和 IMU,并排除音频",
|
||||
"key": "SYNCHRONIZED_SIDECARS",
|
||||
"type": "boolean",
|
||||
"value": "false"
|
||||
},
|
||||
{
|
||||
"description": "是否允许最终验收决定排除 HeadPose 或 HandPose 而继续交付基础数据",
|
||||
"key": "ALLOW_POSE_EXCLUSION",
|
||||
"type": "boolean",
|
||||
"value": "false"
|
||||
}
|
||||
],
|
||||
"id": "operator-builtin-package",
|
||||
@ -7758,16 +7770,56 @@
|
||||
"transmission": "oss",
|
||||
"type": "json"
|
||||
},
|
||||
{
|
||||
"container": "single",
|
||||
"description": "自动生成的 WiLoR 3D HandPose 逐帧结果",
|
||||
"id": "handpose",
|
||||
{
|
||||
"container": "single",
|
||||
"description": "自动生成的 WiLoR 3D HandPose 逐帧结果",
|
||||
"id": "handpose",
|
||||
"name": "handpose",
|
||||
"payloadMode": "ref",
|
||||
"role": "annotation",
|
||||
"transmission": "oss",
|
||||
"type": "json"
|
||||
}
|
||||
"transmission": "oss",
|
||||
"type": "json"
|
||||
},
|
||||
{
|
||||
"container": "collection",
|
||||
"description": "左相机逐帧硬件 PTS CSV;v5.8 按绝对时间窗口同步裁切",
|
||||
"id": "leftTimestamps",
|
||||
"name": "leftTimestamps",
|
||||
"payloadMode": "ref",
|
||||
"role": "pts",
|
||||
"transmission": "oss",
|
||||
"type": "file"
|
||||
},
|
||||
{
|
||||
"container": "collection",
|
||||
"description": "右相机逐帧硬件 PTS CSV;v5.8 按绝对时间窗口同步裁切",
|
||||
"id": "rightTimestamps",
|
||||
"name": "rightTimestamps",
|
||||
"payloadMode": "ref",
|
||||
"role": "pts",
|
||||
"transmission": "oss",
|
||||
"type": "file"
|
||||
},
|
||||
{
|
||||
"container": "collection",
|
||||
"description": "与双目视频同硬件时钟的 accel/gyro IMU CSV",
|
||||
"id": "imu",
|
||||
"name": "imu",
|
||||
"payloadMode": "ref",
|
||||
"role": "imu",
|
||||
"transmission": "oss",
|
||||
"type": "file"
|
||||
},
|
||||
{
|
||||
"container": "collection",
|
||||
"description": "原始相机与 IMU calibration 文件;不切分、不改写",
|
||||
"id": "calibrations",
|
||||
"name": "calibrations",
|
||||
"payloadMode": "ref",
|
||||
"role": "calibration",
|
||||
"transmission": "oss",
|
||||
"type": "file"
|
||||
}
|
||||
],
|
||||
"name": "成品打包",
|
||||
"outputs": [
|
||||
|
||||
@ -20,6 +20,7 @@ const fanyuDeliveryTemplateV54ID = "template-fanyu-left-camera-delivery-v5-4"
|
||||
const fanyuDeliveryTemplateV55ID = "template-fanyu-left-camera-delivery-v5-5"
|
||||
const fanyuDeliveryTemplateV56ID = "template-fanyu-stereo-pose-delivery-v5-6"
|
||||
const fanyuDeliveryTemplateV57ID = "template-fanyu-stereo-prelabel-delivery-v5-7"
|
||||
const fanyuDeliveryTemplateV58ID = "template-fanyu-stereo-synchronized-delivery-v5-8"
|
||||
|
||||
func fanyuLegacyPorts(operatorID string, inputs []domain.PortDefinition, outputs []domain.PortDefinition) ([]domain.PortDefinition, []domain.PortDefinition) {
|
||||
legacy := func(id, name string, typ domain.PortType, required bool) domain.PortDefinition {
|
||||
@ -167,6 +168,17 @@ func fanyuEdge(id string, source string, sourceHandle string, target string, tar
|
||||
return domain.WorkflowEdge{ID: id, Source: source, SourceHandle: sourceHandle, Target: target, TargetHandle: targetHandle, Animated: true}
|
||||
}
|
||||
|
||||
func fanyuUpsertHyperparam(items []domain.HyperParam, key string, value string) []domain.HyperParam {
|
||||
updated := append([]domain.HyperParam(nil), items...)
|
||||
for index := range updated {
|
||||
if updated[index].Key == key {
|
||||
updated[index].Value = value
|
||||
return updated
|
||||
}
|
||||
}
|
||||
return append(updated, domain.HyperParam{Key: key, Value: value, Type: "string"})
|
||||
}
|
||||
|
||||
func (server *server) ensureFanyuDeliveryTemplate(ctx context.Context, organizationID string) error {
|
||||
organizationID = normalizedOrganizationID(organizationID)
|
||||
if err := server.ensureFanyuDeliveryTemplateV1(ctx, organizationID); err != nil {
|
||||
@ -196,12 +208,15 @@ func (server *server) ensureFanyuDeliveryTemplate(ctx context.Context, organizat
|
||||
if err := server.ensureFanyuDeliveryTemplateV57(ctx, organizationID); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := server.ensureFanyuDeliveryTemplateV58(ctx, organizationID); err != nil {
|
||||
return err
|
||||
}
|
||||
return server.ensureFanyuConvenienceStoreAnnotationTemplates(ctx, organizationID)
|
||||
}
|
||||
|
||||
func (server *server) ensureFanyuConvenienceStoreAnnotationTemplates(ctx context.Context, organizationID string) error {
|
||||
organizationID = normalizedOrganizationID(organizationID)
|
||||
for version := 1; version <= 5; version++ {
|
||||
for version := 1; version <= 6; version++ {
|
||||
templateID := fmt.Sprintf("tpl-fanyu-convenience-store-v%d-%s", version, organizationID)
|
||||
existing, err := server.store.GetAnnotationTemplate(ctx, templateID)
|
||||
if err != nil {
|
||||
@ -209,6 +224,9 @@ func (server *server) ensureFanyuConvenienceStoreAnnotationTemplates(ctx context
|
||||
}
|
||||
if existing == nil {
|
||||
template := domain.DefaultConvenienceStoreAnnotationTemplate(organizationID, "", version)
|
||||
if version == 6 {
|
||||
template.HumanStages = domain.DefaultFanyuV58HumanStages()
|
||||
}
|
||||
now := nowISO()
|
||||
template.CreatedAt = now
|
||||
template.UpdatedAt = now
|
||||
@ -219,6 +237,15 @@ func (server *server) ensureFanyuConvenienceStoreAnnotationTemplates(ctx context
|
||||
}
|
||||
continue
|
||||
}
|
||||
if version == 6 && !domain.IsFanyuV58ThreeRoleHumanLoop(existing.HumanStages) {
|
||||
updated := *existing
|
||||
updated.HumanStages = domain.DefaultFanyuV58HumanStages()
|
||||
updated.UpdatedAt = nowISO()
|
||||
if err := server.store.UpsertAnnotationTemplate(ctx, updated); err != nil {
|
||||
return err
|
||||
}
|
||||
continue
|
||||
}
|
||||
// Early v5 POC deployments persisted a two-stage combined template
|
||||
// under this system-owned ID. Upgrade only that stale stage topology;
|
||||
// preserve its labels, phrases, project binding, and publication record.
|
||||
@ -234,6 +261,93 @@ func (server *server) ensureFanyuConvenienceStoreAnnotationTemplates(ctx context
|
||||
return nil
|
||||
}
|
||||
|
||||
// ensureFanyuDeliveryTemplateV58 publishes the confirmed three-role workflow
|
||||
// and carries stereo PTS, IMU, and calibration sidecars into the final package.
|
||||
// v5.7 remains immutable and readable for historical runs.
|
||||
func (server *server) ensureFanyuDeliveryTemplateV58(ctx context.Context, organizationID string) error {
|
||||
organizationID = normalizedOrganizationID(organizationID)
|
||||
base, err := server.store.GetTemplate(ctx, fanyuDeliveryTemplateV57ID+"-"+organizationID)
|
||||
if err != nil || base == nil {
|
||||
return err
|
||||
}
|
||||
templateID := fanyuDeliveryTemplateV58ID + "-" + organizationID
|
||||
releaseID := "workflow-release-fanyu-v5-8-" + organizationID
|
||||
nodes := append([]domain.WorkflowNode(nil), base.Nodes...)
|
||||
annotationTemplateID := fmt.Sprintf("tpl-fanyu-convenience-store-v6-%s", organizationID)
|
||||
for index := range nodes {
|
||||
node := &nodes[index]
|
||||
switch node.ID {
|
||||
case "fanyu-v56-human":
|
||||
node.Data.Label = "真实切分与语义标注→切分/标注审核→整包验收"
|
||||
node.Data.Description = "标注员在一个合并环节完成真实切分和语义标注;审核员统一审核,独立验收员完成整包验收。"
|
||||
node.Data.Hyperparams = fanyuUpsertHyperparam(node.Data.Hyperparams, "ANNOTATION_TEMPLATE_ID", annotationTemplateID)
|
||||
node.Data.Hyperparams = fanyuUpsertHyperparam(node.Data.Hyperparams, "RELEASE_POLICY", "all_accepted")
|
||||
node.Data.Hyperparams = fanyuUpsertHyperparam(node.Data.Hyperparams, "REQUIRE_PREPACKAGE_ACCEPTANCE", "true")
|
||||
case "fanyu-v56-package":
|
||||
node.Data.Label = "双目/PTS/IMU 同步切分与自动交付打包"
|
||||
node.Data.Description = "按统一绝对硬件时间窗口裁切左右视频、PTS 和 IMU;排除音频,原样携带 calibration,并按验收决定包含或排除 Pose。"
|
||||
node.Data.Hyperparams = fanyuUpsertHyperparam(node.Data.Hyperparams, "SYNCHRONIZED_SIDECARS", "true")
|
||||
node.Data.Hyperparams = fanyuUpsertHyperparam(node.Data.Hyperparams, "ALLOW_POSE_EXCLUSION", "true")
|
||||
}
|
||||
}
|
||||
edges := append([]domain.WorkflowEdge(nil), base.Edges...)
|
||||
edges = append(edges,
|
||||
fanyuEdge("fanyu-v58-e23", "fanyu-v56-undistort", "leftRectifiedTimestamps", "fanyu-v56-package", "leftTimestamps"),
|
||||
fanyuEdge("fanyu-v58-e24", "fanyu-v56-undistort", "rightRectifiedTimestamps", "fanyu-v56-package", "rightTimestamps"),
|
||||
fanyuEdge("fanyu-v58-e25", "fanyu-v56-normalize", "imu", "fanyu-v56-package", "imu"),
|
||||
fanyuEdge("fanyu-v58-e26", "fanyu-v56-normalize", "calibrations", "fanyu-v56-package", "calibrations"),
|
||||
)
|
||||
now := nowISO()
|
||||
createdAt := now
|
||||
if existing, existingErr := server.store.GetTemplate(ctx, templateID); existingErr != nil {
|
||||
return existingErr
|
||||
} else if existing != nil && strings.TrimSpace(existing.CreatedAt) != "" {
|
||||
createdAt = existing.CreatedAt
|
||||
}
|
||||
template := domain.TemplateRecord{
|
||||
ID: templateID, OrganizationID: organizationID, Name: "01-双目/PTS/IMU 同步切分交付-v5.8",
|
||||
Description: "双目去畸变与脱敏、Qwen 粗切、三角色合并人工处理、独立整包验收,以及左右视频/PTS/IMU 同步切分自动打包;音频不处理不交付,calibration 原样保留。",
|
||||
Type: domain.WorkflowTypeBatch, Kind: domain.WorkflowKindStandard, ExecutionScope: domain.WorkflowExecutionScopeProduction,
|
||||
DefinitionState: domain.WorkflowDefinitionStateDraft, DefinitionVersion: 8, DefinitionFamilyID: fanyuDeliveryTemplateV5ID + "-" + organizationID, SupersedesTemplateID: fanyuDeliveryTemplateV57ID + "-" + organizationID,
|
||||
MaxConcurrentRuns: 1, WorkflowInputs: append([]domain.WorkflowInputDefinition(nil), base.WorkflowInputs...), Nodes: nodes, Edges: edges, CreatedAt: createdAt, UpdatedAt: now,
|
||||
}
|
||||
if issues := validateWorkflowTopology(nodes, edges); len(issues) > 0 {
|
||||
return fmt.Errorf("invalid fanyu v5.8 template: %s", strings.TrimSpace(issues[0].Message))
|
||||
}
|
||||
if issues := validateWorkflowInputContract(nodes, edges, template.WorkflowInputs, true); len(issues) > 0 {
|
||||
return fmt.Errorf("invalid fanyu v5.8 input contract: %s", strings.TrimSpace(issues[0].Message))
|
||||
}
|
||||
if err := server.store.UpsertTemplate(ctx, template); err != nil {
|
||||
return err
|
||||
}
|
||||
if existingRelease, releaseErr := server.store.GetWorkflowRelease(ctx, releaseID); releaseErr != nil || existingRelease != nil {
|
||||
return releaseErr
|
||||
}
|
||||
if len(server.validateWorkflowOperatorPublication(ctx, nodes, domain.WorkflowExecutionScopeProduction)) > 0 {
|
||||
return nil
|
||||
}
|
||||
for _, node := range nodes {
|
||||
if node.ID != "fanyu-v56-human" {
|
||||
continue
|
||||
}
|
||||
for _, parameter := range node.Data.Hyperparams {
|
||||
if parameter.Key == "ANNOTATION_WORKGROUP_ID" && strings.TrimSpace(fmt.Sprint(parameter.Value)) == "" {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
release := domain.WorkflowReleaseRecord{
|
||||
ID: releaseID, OrganizationID: organizationID, TemplateID: template.ID, Version: 8, Name: template.Name, Description: template.Description,
|
||||
Type: template.Type, Kind: template.Kind, ExecutionScope: template.ExecutionScope, MaxConcurrentRuns: template.MaxConcurrentRuns,
|
||||
WorkflowInputs: template.WorkflowInputs, Nodes: nodes, Edges: edges,
|
||||
Capabilities: []string{"directory_input", "stereo_opencv_undistort", "stereo_yunet_face_anonymization", "qwen3vl_behavior_rough_cut", "combined_cut_semantic_annotation", "combined_quality_review", "independent_full_acceptance", "stereo_pts_imu_synchronized_crop", "automatic_package"},
|
||||
RequiredPluginIDs: []string{pluginregistry.HumanLoopCoreID, pluginregistry.AnnotationQAID}, ContentDigest: workflowReleaseDigest(template),
|
||||
ReleaseNotes: "v5.8 three-role human loop and absolute-timestamp synchronized stereo/PTS/IMU package",
|
||||
PublishedByUserID: "system", PublishedAt: now, CreatedAt: now,
|
||||
}
|
||||
return server.store.UpsertWorkflowRelease(ctx, release)
|
||||
}
|
||||
|
||||
// ensureFanyuDeliveryTemplateV5 adds a new immutable left-camera route and
|
||||
// intentionally never mutates v1-v4. It is saved as an editable template
|
||||
// until independently built images, a verified Qwen3-VL cache, and the real
|
||||
|
||||
@ -531,4 +531,44 @@ func TestEnsureFanyuDeliveryTemplateV56BuildsStereoCropAndPoseTopology(t *testin
|
||||
if !reviewEdges["head"] || reviewEdges["hand"] {
|
||||
t.Fatalf("v5.7 must review HeadPose but bypass human review for HandPose: %#v", reviewEdges)
|
||||
}
|
||||
v58, v58Err := dataStore.GetTemplate(ctx, fanyuDeliveryTemplateV58ID+"-org-v56")
|
||||
if v58Err != nil || v58 == nil {
|
||||
t.Fatalf("v5.8 template=%#v err=%v", v58, v58Err)
|
||||
}
|
||||
if v58.DefinitionVersion != 8 || v58.SupersedesTemplateID != fanyuDeliveryTemplateV57ID+"-org-v56" || len(v58.Nodes) != 10 || len(v58.Edges) != 26 {
|
||||
t.Fatalf("unexpected v5.8 synchronized topology: %#v", v58)
|
||||
}
|
||||
v58Package := fanyuTestNode(v58.Nodes, "fanyu-v56-package")
|
||||
v58Human := fanyuTestNode(v58.Nodes, "fanyu-v56-human")
|
||||
if v58Package == nil || fanyuTestHyperparam(v58Package, "SYNCHRONIZED_SIDECARS") != "true" || fanyuTestHyperparam(v58Package, "ALLOW_POSE_EXCLUSION") != "true" {
|
||||
t.Fatalf("v5.8 package must enable synchronized sidecars and pose exclusion: %#v", v58Package)
|
||||
}
|
||||
if v58Human == nil || fanyuTestHyperparam(v58Human, "ANNOTATION_TEMPLATE_ID") != "tpl-fanyu-convenience-store-v6-org-v56" {
|
||||
t.Fatalf("v5.8 human node must use the three-role annotation template: %#v", v58Human)
|
||||
}
|
||||
requiredV58Edges := map[string]bool{"leftPts": false, "rightPts": false, "imu": false, "calibrations": false}
|
||||
for _, edge := range v58.Edges {
|
||||
if edge.Target != "fanyu-v56-package" {
|
||||
continue
|
||||
}
|
||||
switch edge.TargetHandle {
|
||||
case "leftTimestamps":
|
||||
requiredV58Edges["leftPts"] = true
|
||||
case "rightTimestamps":
|
||||
requiredV58Edges["rightPts"] = true
|
||||
case "imu":
|
||||
requiredV58Edges["imu"] = true
|
||||
case "calibrations":
|
||||
requiredV58Edges["calibrations"] = true
|
||||
}
|
||||
}
|
||||
for name, found := range requiredV58Edges {
|
||||
if !found {
|
||||
t.Fatalf("v5.8 missing synchronized package edge %s", name)
|
||||
}
|
||||
}
|
||||
v6Annotation, annotationErr := dataStore.GetAnnotationTemplate(ctx, "tpl-fanyu-convenience-store-v6-org-v56")
|
||||
if annotationErr != nil || v6Annotation == nil || !domain.IsFanyuV58ThreeRoleHumanLoop(v6Annotation.HumanStages) {
|
||||
t.Fatalf("v5.8 annotation template=%#v err=%v", v6Annotation, annotationErr)
|
||||
}
|
||||
}
|
||||
|
||||
@ -322,3 +322,82 @@ func TestFanyuV5FourStageProgressesToConfirmOnlyAggregateAcceptance(t *testing.T
|
||||
t.Fatalf("aggregate acceptance must remain confirm-only for quality_reviewer: batch=%#v err=%v", aggregateBatch, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFanyuV58AggregateAcceptanceUsesIndependentRoleAndWholeBatchRejection(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
dataStore := store.NewMemoryStore()
|
||||
now := nowISO()
|
||||
quality := domain.UserRecord{ID: "quality-v58", OrganizationID: domain.DefaultOrganizationID, Role: domain.UserRoleQualityReviewer, Status: domain.UserStatusActive}
|
||||
acceptance := domain.UserRecord{ID: "acceptance-v58", OrganizationID: domain.DefaultOrganizationID, Role: domain.UserRoleAcceptanceReviewer, Status: domain.UserStatusActive}
|
||||
for _, user := range []domain.UserRecord{quality, acceptance} {
|
||||
if err := dataStore.UpsertUser(ctx, user); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
for _, membership := range []domain.ProjectAnnotationMembershipRecord{
|
||||
{ID: "quality-membership-v58", OrganizationID: domain.DefaultOrganizationID, ProjectID: "project-v58", UserID: quality.ID, WorkgroupID: "workgroup-v58", VendorID: "vendor-v58", AssignmentRole: domain.AnnotationRoleQualityReviewer, CreatedAt: now, UpdatedAt: now},
|
||||
{ID: "acceptance-membership-v58", OrganizationID: domain.DefaultOrganizationID, ProjectID: "project-v58", UserID: acceptance.ID, WorkgroupID: "workgroup-v58", VendorID: "vendor-v58", AssignmentRole: domain.AnnotationRoleAcceptanceReviewer, CreatedAt: now, UpdatedAt: now},
|
||||
} {
|
||||
if err := dataStore.UpsertProjectAnnotationMembership(ctx, membership); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
batch := domain.HumanBatchRecord{ID: "batch-v58", OrganizationID: domain.DefaultOrganizationID, PluginID: "annotation-qa", ProjectID: "project-v58", WorkflowID: "workflow-v58", RunID: "run-v58", GateNodeID: "human-v58", Status: domain.HumanBatchActive, Stages: domain.DefaultFanyuV58HumanStages(), ReleasePolicy: domain.HumanReleaseAllAccepted, MaxReworkRounds: 5, RequirePrePackageAcceptance: true, CreatedAt: now, UpdatedAt: now}
|
||||
if err := dataStore.UpsertHumanBatch(ctx, batch); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
task := domain.AnnotationTaskRecord{ID: "task-v58", OrganizationID: domain.DefaultOrganizationID, ProjectID: batch.ProjectID, WorkflowID: batch.WorkflowID, RunID: batch.RunID, NodeID: batch.GateNodeID, ArtifactID: "artifact-v58", SourceVideo: "bos://fixture/video.mp4", ClipStart: 0, ClipEnd: 20, TemplateID: "template-v58", TemplateVersion: 6, WorkgroupID: "workgroup-v58", VendorID: "vendor-v58", Status: domain.AnnotationTaskStatusAccepted, CurrentRevision: 1, CreatedAt: now, UpdatedAt: now}
|
||||
if err := dataStore.UpsertAnnotationTask(ctx, task); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := dataStore.UpsertSliceRevision(ctx, domain.SliceRevisionRecord{ID: "slice-v58", OrganizationID: domain.DefaultOrganizationID, TaskID: task.ID, Revision: 1, Segments: []domain.SliceSegment{{ID: "slice", Start: 0, End: 20}}, AuthorUserID: "annotator-v58", CreatedAt: now}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := dataStore.UpsertAnnotationRevision(ctx, domain.AnnotationRevisionRecord{ID: "revision-v58", OrganizationID: domain.DefaultOrganizationID, TaskID: task.ID, Revision: 1, TemplateVersion: 6, Segments: []domain.AnnotationSegment{{ID: "semantic", LabelID: "01", Label: "测试", Start: 0, End: 20}}, AuthorUserID: "annotator-v58", CreatedAt: now}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
item := domain.HumanItemRecord{ID: "item-v58", OrganizationID: domain.DefaultOrganizationID, PluginID: "annotation-qa", BatchID: batch.ID, ProjectID: batch.ProjectID, WorkflowID: batch.WorkflowID, RunID: batch.RunID, GateNodeID: batch.GateNodeID, LegacyTaskID: task.ID, Subject: domain.HumanSubjectRef{ArtifactID: task.ArtifactID, ItemKey: "clip-v58"}, CurrentStageID: domain.FanyuV58StageQualityReview, Status: domain.HumanItemAccepted, WorkgroupID: task.WorkgroupID, VendorID: task.VendorID, CurrentRevision: 1, MaxReworkRounds: 5, Version: 2, AcceptedAt: now, AcceptedByUserID: quality.ID, CreatedAt: now, UpdatedAt: now}
|
||||
if err := dataStore.UpsertHumanItem(ctx, item); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
server := &server{store: dataStore}
|
||||
confirmed, err := server.ensureFanyuV5PrePackageAcceptance(ctx, &batch)
|
||||
if err != nil || confirmed {
|
||||
t.Fatalf("create v5.8 acceptance confirmed=%v err=%v", confirmed, err)
|
||||
}
|
||||
aggregate, _ := dataStore.GetHumanItem(ctx, fanyuV5PrePackageAcceptanceItemID(batch.ID))
|
||||
aggregateBatch, _ := dataStore.GetHumanBatch(ctx, aggregate.BatchID)
|
||||
if aggregate == nil || aggregateBatch == nil || aggregateBatch.Stages[0].RequiredRole != "acceptance_reviewer" || aggregateBatch.Stages[0].ConfirmOnly {
|
||||
t.Fatalf("unexpected v5.8 aggregate acceptance: item=%#v batch=%#v", aggregate, aggregateBatch)
|
||||
}
|
||||
handler := NewHandler(dataStore, nil)
|
||||
request := func(method, path string, user domain.UserRecord, body any) *httptest.ResponseRecorder {
|
||||
encoded, _ := json.Marshal(body)
|
||||
req := httptest.NewRequest(method, path, bytes.NewReader(encoded))
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
csrf := "v58-csrf"
|
||||
req.AddCookie(&http.Cookie{Name: csrfCookieName, Value: csrf})
|
||||
req.Header.Set(csrfHeaderName, csrf)
|
||||
req = req.WithContext(context.WithValue(req.Context(), authContextKey{}, &authenticatedPrincipal{User: user, Organization: domain.OrganizationRecord{ID: domain.DefaultOrganizationID, Status: domain.OrganizationStatusActive}}))
|
||||
recorder := httptest.NewRecorder()
|
||||
handler.ServeHTTP(recorder, req)
|
||||
return recorder
|
||||
}
|
||||
qualityClaim := request(http.MethodPost, "/api/human-items/"+aggregate.ID+"/claim", quality, map[string]any{"version": aggregate.Version})
|
||||
if qualityClaim.Code != http.StatusForbidden {
|
||||
t.Fatalf("quality reviewer must not claim v5.8 acceptance: status=%d body=%s", qualityClaim.Code, qualityClaim.Body.String())
|
||||
}
|
||||
claim := request(http.MethodPost, "/api/human-items/"+aggregate.ID+"/claim", acceptance, map[string]any{"version": aggregate.Version})
|
||||
if claim.Code != http.StatusOK {
|
||||
t.Fatalf("acceptance claim status=%d body=%s", claim.Code, claim.Body.String())
|
||||
}
|
||||
claimed, _ := dataStore.GetHumanItem(ctx, aggregate.ID)
|
||||
reject := request(http.MethodPost, "/api/human-items/"+aggregate.ID+"/decisions", acceptance, map[string]any{"version": claimed.Version, "decision": "rejected", "reasonCodes": []string{"batch_problem"}, "comment": "整包退回审核"})
|
||||
if reject.Code != http.StatusOK {
|
||||
t.Fatalf("acceptance reject status=%d body=%s", reject.Code, reject.Body.String())
|
||||
}
|
||||
routed, _ := dataStore.GetHumanItem(ctx, item.ID)
|
||||
if routed.CurrentStageID != domain.FanyuV58StageQualityReview || routed.Status != domain.HumanItemSubmitted || routed.AcceptedAt != "" {
|
||||
t.Fatalf("whole-batch rejection must route source item to quality review: %#v", routed)
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,16 +32,17 @@ type humanSubmissionRequest struct {
|
||||
}
|
||||
|
||||
type humanDecisionRequest struct {
|
||||
Version int `json:"version"`
|
||||
Decision domain.HumanDecision `json:"decision"`
|
||||
ReviewedRevision int `json:"reviewedRevision"`
|
||||
RejectTargets []string `json:"rejectTargets"`
|
||||
ReasonCodes []string `json:"reasonCodes"`
|
||||
Comment string `json:"comment"`
|
||||
VideoQuality string `json:"videoQuality,omitempty"`
|
||||
AnnotationAccuracy float64 `json:"annotationAccuracy,omitempty"`
|
||||
AnnotationCompleteness float64 `json:"annotationCompleteness,omitempty"`
|
||||
OverallGrade string `json:"overallGrade,omitempty"`
|
||||
Version int `json:"version"`
|
||||
Decision domain.HumanDecision `json:"decision"`
|
||||
ReviewedRevision int `json:"reviewedRevision"`
|
||||
RejectTargets []string `json:"rejectTargets"`
|
||||
ReasonCodes []string `json:"reasonCodes"`
|
||||
Comment string `json:"comment"`
|
||||
VideoQuality string `json:"videoQuality,omitempty"`
|
||||
AnnotationAccuracy float64 `json:"annotationAccuracy,omitempty"`
|
||||
AnnotationCompleteness float64 `json:"annotationCompleteness,omitempty"`
|
||||
OverallGrade string `json:"overallGrade,omitempty"`
|
||||
PoseDelivery domain.PoseDeliveryPolicy `json:"poseDelivery,omitempty"`
|
||||
}
|
||||
|
||||
type humanReopenRequest struct {
|
||||
@ -293,13 +294,22 @@ func isFanyuV5FourStageBatch(batch *domain.HumanBatchRecord) bool {
|
||||
return batch != nil && domain.IsFanyuV5FourStageHumanLoop(batch.Stages)
|
||||
}
|
||||
|
||||
func isFanyuV58ThreeRoleBatch(batch *domain.HumanBatchRecord) bool {
|
||||
return batch != nil && domain.IsFanyuV58ThreeRoleHumanLoop(batch.Stages)
|
||||
}
|
||||
|
||||
func annotationRoleForHumanStage(stage domain.HumanStageDefinition) domain.AnnotationAssignmentRole {
|
||||
switch stage.ID {
|
||||
case "split_annotation", domain.FanyuV5StageCutAdjustment:
|
||||
return domain.AnnotationRoleCutter
|
||||
case "split_quality_review", domain.FanyuV5StageCutReview, domain.FanyuV5StageSemanticAnnotation:
|
||||
return domain.AnnotationRoleAnnotator
|
||||
case "quality_review", domain.FanyuV5StageSemanticReview, "acceptance", fanyuV5PrePackageAcceptanceStageID:
|
||||
case "quality_review", domain.FanyuV5StageSemanticReview:
|
||||
return domain.AnnotationRoleQualityReviewer
|
||||
case "acceptance", fanyuV5PrePackageAcceptanceStageID:
|
||||
if stage.RequiredRole == "acceptance_reviewer" {
|
||||
return domain.AnnotationRoleAcceptanceReviewer
|
||||
}
|
||||
return domain.AnnotationRoleQualityReviewer
|
||||
}
|
||||
switch stage.RequiredRole {
|
||||
@ -308,7 +318,7 @@ func annotationRoleForHumanStage(stage domain.HumanStageDefinition) domain.Annot
|
||||
case "quality_reviewer":
|
||||
return domain.AnnotationRoleQualityReviewer
|
||||
case "acceptance_reviewer":
|
||||
return domain.AnnotationRoleQualityReviewer
|
||||
return domain.AnnotationRoleAcceptanceReviewer
|
||||
default:
|
||||
return domain.AnnotationRoleAnnotator
|
||||
}
|
||||
@ -726,9 +736,10 @@ func userRoleSupportsAnnotationAssignment(role domain.UserRole, assignmentRole d
|
||||
return role == domain.UserRoleCutter
|
||||
case domain.AnnotationRoleAnnotator:
|
||||
return role == domain.UserRoleAnnotator || role == domain.UserRoleDataOperator
|
||||
case domain.AnnotationRoleQualityReviewer, domain.AnnotationRoleAcceptanceReviewer:
|
||||
return role == domain.UserRoleQualityReviewer || role == domain.UserRoleAcceptanceReviewer ||
|
||||
role == domain.UserRoleQAReviewer || role == domain.UserRoleAuditor || role == domain.UserRoleComplianceAuditor
|
||||
case domain.AnnotationRoleQualityReviewer:
|
||||
return role == domain.UserRoleQualityReviewer || role == domain.UserRoleQAReviewer || role == domain.UserRoleAuditor || role == domain.UserRoleComplianceAuditor
|
||||
case domain.AnnotationRoleAcceptanceReviewer:
|
||||
return role == domain.UserRoleAcceptanceReviewer
|
||||
default:
|
||||
return false
|
||||
}
|
||||
@ -973,6 +984,11 @@ func (server *server) handleHumanItemDecision(writer http.ResponseWriter, reques
|
||||
renderJSON(writer, http.StatusNotFound, map[string]string{"error": "Human batch not found"})
|
||||
return
|
||||
}
|
||||
strictSourceBatch, v58AggregateAcceptance, sourceErr := v58AggregateSourceBatch(request.Context(), server, batch)
|
||||
if sourceErr != nil {
|
||||
renderError(writer, http.StatusInternalServerError, sourceErr)
|
||||
return
|
||||
}
|
||||
stage, stageIndex, found := humanStage(batch, item.CurrentStageID)
|
||||
if !found || (stage.Kind != domain.HumanStageReview && stage.Kind != domain.HumanStageAcceptance && stage.Kind != domain.HumanStageApproval) {
|
||||
renderJSON(writer, http.StatusConflict, map[string]string{"error": "Current human stage does not accept decisions"})
|
||||
@ -1003,6 +1019,16 @@ func (server *server) handleHumanItemDecision(writer http.ResponseWriter, reques
|
||||
renderValidationError(writer, validationIssue{Field: "decision", Message: "this acceptance stage is confirm-only and does not allow reject or rework"})
|
||||
return
|
||||
}
|
||||
if v58AggregateAcceptance && payload.Decision == domain.HumanDecisionApproved {
|
||||
if !validPoseDeliveryDecision(payload.PoseDelivery.Headpose) || !validPoseDeliveryDecision(payload.PoseDelivery.Handpose) {
|
||||
renderValidationError(writer, validationIssue{Field: "poseDelivery", Message: "headpose and handpose must be include or exclude"})
|
||||
return
|
||||
}
|
||||
if (payload.PoseDelivery.Headpose == domain.PoseDeliveryExclude || payload.PoseDelivery.Handpose == domain.PoseDeliveryExclude) && len(payload.PoseDelivery.ReasonCodes) == 0 {
|
||||
renderValidationError(writer, validationIssue{Field: "poseDelivery.reasonCodes", Message: "pose exclusion requires at least one reason code"})
|
||||
return
|
||||
}
|
||||
}
|
||||
if stage.ConfirmOnly && (strings.TrimSpace(payload.VideoQuality) == "" || strings.TrimSpace(payload.OverallGrade) == "" || payload.AnnotationAccuracy < 0 || payload.AnnotationAccuracy > 100 || payload.AnnotationCompleteness < 0 || payload.AnnotationCompleteness > 100) {
|
||||
renderValidationError(writer, validationIssue{Field: "statistics", Message: "confirm-only acceptance requires videoQuality, overallGrade and annotation accuracy/completeness in [0,100]"})
|
||||
return
|
||||
@ -1023,6 +1049,12 @@ func (server *server) handleHumanItemDecision(writer http.ResponseWriter, reques
|
||||
statistics["overallGrade"] = strings.TrimSpace(payload.OverallGrade)
|
||||
item.Subject.Payload["statistics"] = statistics
|
||||
}
|
||||
if v58AggregateAcceptance {
|
||||
if item.Subject.Payload == nil {
|
||||
item.Subject.Payload = map[string]any{}
|
||||
}
|
||||
item.Subject.Payload["poseDelivery"] = payload.PoseDelivery
|
||||
}
|
||||
eventType := string(payload.Decision)
|
||||
automaticReworkTarget := ""
|
||||
rejectAllowedStages := []string(nil)
|
||||
@ -1044,6 +1076,10 @@ func (server *server) handleHumanItemDecision(writer http.ResponseWriter, reques
|
||||
return
|
||||
}
|
||||
rejectAllowedStages = allowedHumanReopenStages(batch, previousStage)
|
||||
if v58AggregateAcceptance {
|
||||
rejectAllowedStages = []string{domain.FanyuV58StageQualityReview}
|
||||
payload.RejectTargets = []string{domain.FanyuV58StageQualityReview}
|
||||
}
|
||||
if isFanyuV5FourStageBatch(batch) {
|
||||
if len(stage.RejectTargets) == 0 {
|
||||
renderJSON(writer, http.StatusConflict, map[string]string{"error": "v5 review stage has no configured rework target", "code": "human_item_stage_contract"})
|
||||
@ -1121,6 +1157,14 @@ func (server *server) handleHumanItemDecision(writer http.ResponseWriter, reques
|
||||
return
|
||||
}
|
||||
}
|
||||
if v58AggregateAcceptance && payload.Decision == domain.HumanDecisionRejected {
|
||||
if err := server.routeV58AcceptanceRejection(request.Context(), strictSourceBatch, principal.User.ID, payload.ReasonCodes, payload.Comment); err != nil {
|
||||
renderError(writer, http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
batch.Status = domain.HumanBatchBlocked
|
||||
_ = server.store.UpsertHumanBatch(request.Context(), *batch)
|
||||
}
|
||||
_ = server.appendHumanEvent(request.Context(), *item, eventType, principal.User.ID, map[string]any{
|
||||
"decision": payload.Decision, "reviewedRevision": payload.ReviewedRevision, "rejectTargets": payload.RejectTargets,
|
||||
"reasonCodes": payload.ReasonCodes, "comment": strings.TrimSpace(payload.Comment), "routedToStage": automaticReworkTarget, "videoQuality": payload.VideoQuality, "annotationAccuracy": payload.AnnotationAccuracy, "annotationCompleteness": payload.AnnotationCompleteness, "overallGrade": payload.OverallGrade,
|
||||
@ -1156,6 +1200,59 @@ func (server *server) handleHumanItemDecision(writer http.ResponseWriter, reques
|
||||
renderJSON(writer, http.StatusOK, item)
|
||||
}
|
||||
|
||||
func (server *server) routeV58AcceptanceRejection(ctx context.Context, source *domain.HumanBatchRecord, actorUserID string, reasonCodes []string, comment string) error {
|
||||
if source == nil || !domain.IsFanyuV58ThreeRoleHumanLoop(source.Stages) {
|
||||
return fmt.Errorf("v5.8 aggregate acceptance source batch is unavailable")
|
||||
}
|
||||
items, err := server.store.ListHumanItems(ctx, source.OrganizationID, domain.HumanItemQuery{BatchID: source.ID})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for index := range items {
|
||||
item := items[index]
|
||||
if strings.TrimSpace(item.ReleasePartitionID) != "" {
|
||||
return fmt.Errorf("v5.8 accepted item %s was already released before final acceptance", item.ID)
|
||||
}
|
||||
previousVersion := item.Version
|
||||
item.CurrentStageID = domain.FanyuV58StageQualityReview
|
||||
item.Status = domain.HumanItemSubmitted
|
||||
item.AssignedUserID = ""
|
||||
item.ClaimedAt = ""
|
||||
item.AcceptedAt = ""
|
||||
item.AcceptedByUserID = ""
|
||||
item.RejectedAt = ""
|
||||
item.ReviewRound++
|
||||
item.Version++
|
||||
item.UpdatedAt = nowISO()
|
||||
updated, updateErr := server.store.UpdateHumanItemVersioned(ctx, item, previousVersion)
|
||||
if updateErr != nil || !updated {
|
||||
if updateErr != nil {
|
||||
return updateErr
|
||||
}
|
||||
return fmt.Errorf("v5.8 item %s version conflict during whole-batch rejection", item.ID)
|
||||
}
|
||||
if strings.TrimSpace(item.LegacyTaskID) != "" {
|
||||
task, taskErr := server.store.GetAnnotationTask(ctx, item.LegacyTaskID)
|
||||
if taskErr != nil {
|
||||
return taskErr
|
||||
}
|
||||
if task != nil {
|
||||
task.Status = domain.AnnotationTaskStatusPendingQuality
|
||||
task.AssignedUserID = ""
|
||||
if taskErr = server.store.UpsertAnnotationTask(ctx, *task); taskErr != nil {
|
||||
return taskErr
|
||||
}
|
||||
}
|
||||
}
|
||||
_ = server.store.UpsertHumanStageAttempt(ctx, domain.HumanStageAttemptRecord{OrganizationID: item.OrganizationID, ItemID: item.ID, StageID: item.CurrentStageID, Round: item.ReviewRound, Status: item.Status})
|
||||
_ = server.appendHumanEvent(ctx, item, "aggregate_acceptance_rejected", actorUserID, map[string]any{"reasonCodes": reasonCodes, "comment": strings.TrimSpace(comment), "routedToStage": domain.FanyuV58StageQualityReview})
|
||||
}
|
||||
source.Status = domain.HumanBatchActive
|
||||
source.AcceptedCount = 0
|
||||
source.UpdatedAt = nowISO()
|
||||
return server.store.UpsertHumanBatch(ctx, *source)
|
||||
}
|
||||
|
||||
func (server *server) handleHumanRejectsList(writer http.ResponseWriter, request *http.Request) {
|
||||
items, err := server.store.ListHumanRejects(request.Context(), server.requestOrganizationID(request), parseHumanRejectQuery(request))
|
||||
if err != nil {
|
||||
@ -1462,6 +1559,21 @@ func acceptanceArtifactRefs(value any) []map[string]any {
|
||||
return refs
|
||||
}
|
||||
|
||||
func validPoseDeliveryDecision(value domain.PoseDeliveryDecision) bool {
|
||||
return value == domain.PoseDeliveryInclude || value == domain.PoseDeliveryExclude
|
||||
}
|
||||
|
||||
func v58AggregateSourceBatch(ctx context.Context, server *server, batch *domain.HumanBatchRecord) (*domain.HumanBatchRecord, bool, error) {
|
||||
if batch == nil || strings.TrimSpace(batch.SourceBatchID) == "" {
|
||||
return nil, false, nil
|
||||
}
|
||||
source, err := server.store.GetHumanBatch(ctx, batch.SourceBatchID)
|
||||
if err != nil || source == nil {
|
||||
return source, false, err
|
||||
}
|
||||
return source, domain.IsFanyuV58ThreeRoleHumanLoop(source.Stages), nil
|
||||
}
|
||||
|
||||
// ensureFanyuV5PrePackageAcceptance creates exactly one vendor-scoped,
|
||||
// partition-level acceptance item after every source item has passed the cut
|
||||
// and semantic-review loop. Optional hand/head prelabels and their rendered
|
||||
@ -1486,12 +1598,16 @@ func (server *server) ensureFanyuV5PrePackageAcceptance(ctx context.Context, sou
|
||||
}
|
||||
if acceptanceBatch == nil {
|
||||
now := nowISO()
|
||||
stage := domain.HumanStageDefinition{ID: fanyuV5PrePackageAcceptanceStageID, Label: "包前最终验收(仅确认)", Kind: domain.HumanStageAcceptance, RequiredRole: "quality_reviewer", EditorSchema: "acceptance-statistics/v1", ConfirmOnly: true}
|
||||
if domain.IsFanyuV58ThreeRoleHumanLoop(source.Stages) {
|
||||
stage = domain.HumanStageDefinition{ID: fanyuV5PrePackageAcceptanceStageID, Label: "整包最终验收", Kind: domain.HumanStageAcceptance, RequiredRole: "acceptance_reviewer", EditorSchema: "acceptance-package/v2", RejectTargets: []string{domain.FanyuV58StageQualityReview}}
|
||||
}
|
||||
acceptanceBatch = &domain.HumanBatchRecord{
|
||||
ID: batchID, OrganizationID: source.OrganizationID, PluginID: source.PluginID,
|
||||
ProjectID: source.ProjectID, WorkflowID: source.WorkflowID, RunID: source.RunID,
|
||||
GateNodeID: source.GateNodeID + "-prepackage-acceptance", SourceBatchID: source.ID,
|
||||
Status: domain.HumanBatchActive, ItemCount: 1, MaxReworkRounds: 0,
|
||||
Stages: []domain.HumanStageDefinition{{ID: fanyuV5PrePackageAcceptanceStageID, Label: "包前最终验收(仅确认)", Kind: domain.HumanStageAcceptance, RequiredRole: "quality_reviewer", EditorSchema: "acceptance-statistics/v1", ConfirmOnly: true}},
|
||||
Stages: []domain.HumanStageDefinition{stage},
|
||||
CreatedAt: now, UpdatedAt: now,
|
||||
}
|
||||
if err := server.store.UpsertHumanBatch(ctx, *acceptanceBatch); err != nil {
|
||||
@ -1503,8 +1619,11 @@ func (server *server) ensureFanyuV5PrePackageAcceptance(ctx context.Context, sou
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if acceptanceItem != nil {
|
||||
return acceptanceItem.Status == domain.HumanItemAccepted, nil
|
||||
if acceptanceItem != nil && acceptanceItem.Status == domain.HumanItemAccepted {
|
||||
return true, nil
|
||||
}
|
||||
if acceptanceItem != nil && acceptanceItem.Status != domain.HumanItemRejected {
|
||||
return false, nil
|
||||
}
|
||||
aggregate := make([]map[string]any, 0, len(items))
|
||||
statistics := map[string]any{
|
||||
@ -1584,12 +1703,26 @@ func (server *server) ensureFanyuV5PrePackageAcceptance(ctx context.Context, sou
|
||||
aggregate = append(aggregate, map[string]any{"taskId": task.ID, "runId": task.RunID, "clipArtifactId": task.ArtifactID, "sourceVideo": task.SourceVideo, "clipStart": task.ClipStart, "clipEnd": task.ClipEnd, "finalSlices": latestSlices.Segments, "annotation": latestRevision.Segments, "poseSummary": poseSummary})
|
||||
}
|
||||
now := nowISO()
|
||||
acceptanceItem = &domain.HumanItemRecord{
|
||||
ID: acceptanceID, OrganizationID: source.OrganizationID, PluginID: source.PluginID, BatchID: batchID,
|
||||
ProjectID: source.ProjectID, WorkflowID: source.WorkflowID, RunID: source.RunID, GateNodeID: acceptanceBatch.GateNodeID,
|
||||
Subject: domain.HumanSubjectRef{ItemKey: source.ID, MediaType: "application/json", Payload: map[string]any{"sourceBatchId": source.ID, "items": aggregate, "statistics": statistics}},
|
||||
CurrentStageID: fanyuV5PrePackageAcceptanceStageID, Status: domain.HumanItemReady,
|
||||
WorkgroupID: items[0].WorkgroupID, VendorID: items[0].VendorID, MaxReworkRounds: 0, Version: 1, CreatedAt: now, UpdatedAt: now,
|
||||
if acceptanceItem == nil {
|
||||
acceptanceItem = &domain.HumanItemRecord{
|
||||
ID: acceptanceID, OrganizationID: source.OrganizationID, PluginID: source.PluginID, BatchID: batchID,
|
||||
ProjectID: source.ProjectID, WorkflowID: source.WorkflowID, RunID: source.RunID, GateNodeID: acceptanceBatch.GateNodeID,
|
||||
Subject: domain.HumanSubjectRef{ItemKey: source.ID, MediaType: "application/json", Payload: map[string]any{"sourceBatchId": source.ID, "items": aggregate, "statistics": statistics, "strictThreeRole": domain.IsFanyuV58ThreeRoleHumanLoop(source.Stages)}},
|
||||
CurrentStageID: fanyuV5PrePackageAcceptanceStageID, Status: domain.HumanItemReady,
|
||||
WorkgroupID: items[0].WorkgroupID, VendorID: items[0].VendorID, MaxReworkRounds: source.MaxReworkRounds, Version: 1, CreatedAt: now, UpdatedAt: now,
|
||||
}
|
||||
} else {
|
||||
acceptanceItem.Subject.Payload = map[string]any{"sourceBatchId": source.ID, "items": aggregate, "statistics": statistics, "strictThreeRole": domain.IsFanyuV58ThreeRoleHumanLoop(source.Stages)}
|
||||
acceptanceItem.Status = domain.HumanItemReady
|
||||
acceptanceItem.AssignedUserID = ""
|
||||
acceptanceItem.ClaimedAt = ""
|
||||
acceptanceItem.AcceptedAt = ""
|
||||
acceptanceItem.AcceptedByUserID = ""
|
||||
acceptanceItem.RejectedAt = ""
|
||||
acceptanceItem.Version++
|
||||
acceptanceItem.UpdatedAt = now
|
||||
acceptanceBatch.Status = domain.HumanBatchActive
|
||||
_ = server.store.UpsertHumanBatch(ctx, *acceptanceBatch)
|
||||
}
|
||||
if err := server.store.UpsertHumanItem(ctx, *acceptanceItem); err != nil {
|
||||
return false, err
|
||||
|
||||
@ -55,6 +55,28 @@ const (
|
||||
FanyuV5StageSemanticReview = "semantic_review"
|
||||
)
|
||||
|
||||
// Fanyu v5.8 restores the confirmed three-role production loop. The
|
||||
// annotator owns one atomic cut+semantic submission, the quality reviewer
|
||||
// reviews that complete submission, and a distinct acceptance reviewer owns
|
||||
// the aggregate pre-package decision.
|
||||
const (
|
||||
FanyuV58StageAnnotationCombined = "annotation_combined"
|
||||
FanyuV58StageQualityReview = "quality_review"
|
||||
)
|
||||
|
||||
type PoseDeliveryDecision string
|
||||
|
||||
const (
|
||||
PoseDeliveryInclude PoseDeliveryDecision = "include"
|
||||
PoseDeliveryExclude PoseDeliveryDecision = "exclude"
|
||||
)
|
||||
|
||||
type PoseDeliveryPolicy struct {
|
||||
Headpose PoseDeliveryDecision `json:"headpose" bson:"headpose"`
|
||||
Handpose PoseDeliveryDecision `json:"handpose" bson:"handpose"`
|
||||
ReasonCodes []string `json:"reasonCodes,omitempty" bson:"reasonCodes,omitempty"`
|
||||
}
|
||||
|
||||
type HumanStageDefinition struct {
|
||||
ID string `json:"id" bson:"id"`
|
||||
Label string `json:"label" bson:"label"`
|
||||
@ -280,6 +302,20 @@ func DefaultFanyuV5HumanStages() []HumanStageDefinition {
|
||||
}
|
||||
}
|
||||
|
||||
func DefaultFanyuV58HumanStages() []HumanStageDefinition {
|
||||
return []HumanStageDefinition{
|
||||
{ID: FanyuV58StageAnnotationCombined, Label: "真实切分与语义标注", Kind: HumanStageAnnotation, RequiredRole: "annotator", EditorSchema: "temporal-semantic-annotation/v2"},
|
||||
{ID: FanyuV58StageQualityReview, Label: "切分与标注审核", Kind: HumanStageReview, RequiredRole: "quality_reviewer", RejectTargets: []string{FanyuV58StageAnnotationCombined}},
|
||||
}
|
||||
}
|
||||
|
||||
func IsFanyuV58ThreeRoleHumanLoop(stages []HumanStageDefinition) bool {
|
||||
return len(stages) == 2 &&
|
||||
stages[0].ID == FanyuV58StageAnnotationCombined && stages[0].Kind == HumanStageAnnotation && stages[0].RequiredRole == "annotator" &&
|
||||
stages[1].ID == FanyuV58StageQualityReview && stages[1].Kind == HumanStageReview && stages[1].RequiredRole == "quality_reviewer" &&
|
||||
len(stages[1].RejectTargets) == 1 && stages[1].RejectTargets[0] == FanyuV58StageAnnotationCombined
|
||||
}
|
||||
|
||||
// IsFanyuV5FourStageHumanLoop is deliberately strict: historical v5 combined
|
||||
// batches stay readable through their legacy adapter while newly created v5
|
||||
// work uses the independent cut and semantic review loop.
|
||||
|
||||
@ -24,17 +24,15 @@ var builtin = map[string]domain.PluginManifest{
|
||||
Routes: []domain.PluginRouteContribution{
|
||||
{ID: "clip", Path: "/plugins/annotation-qa/workflows/:workflowId/clip", Label: "人工调切", RequiredRoles: []string{"admin", "cutter"}},
|
||||
{ID: "clip-quality", Path: "/plugins/annotation-qa/workflows/:workflowId/clip-quality", Label: "剪切审核", RequiredRoles: []string{"admin", "annotator"}},
|
||||
{ID: "annotate", Path: "/plugins/annotation-qa/workflows/:workflowId/annotate", Label: "语义标注", RequiredRoles: []string{"admin", "annotator"}},
|
||||
{ID: "quality", Path: "/plugins/annotation-qa/workflows/:workflowId/quality", Label: "标注审核", RequiredRoles: []string{"admin", "quality_reviewer"}},
|
||||
{ID: "acceptance", Path: "/plugins/annotation-qa/workflows/:workflowId/acceptance", Label: "最终验收", RequiredRoles: []string{"admin", "quality_reviewer", "acceptance_reviewer"}},
|
||||
{ID: "annotate", Path: "/plugins/annotation-qa/workflows/:workflowId/annotate", Label: "真实切分与语义标注", RequiredRoles: []string{"admin", "annotator"}},
|
||||
{ID: "quality", Path: "/plugins/annotation-qa/workflows/:workflowId/quality", Label: "切分与标注审核", RequiredRoles: []string{"admin", "quality_reviewer"}},
|
||||
{ID: "acceptance", Path: "/plugins/annotation-qa/workflows/:workflowId/acceptance", Label: "最终验收", RequiredRoles: []string{"admin", "acceptance_reviewer"}},
|
||||
{ID: "item", Path: "/plugins/annotation-qa/items/:itemId", Label: "标注任务详情"},
|
||||
},
|
||||
Navigation: []domain.PluginNavigationContribution{
|
||||
{ID: "annotate", Label: "语义标注", Path: "/plugins/annotation-qa/workflows/all/annotate", Icon: "tags", Order: 10, GroupID: "annotation-center", GroupLabel: "标注中心", GroupIcon: "tags", RequiredRoles: []string{"admin", "annotator"}},
|
||||
{ID: "quality", Label: "标注审核", Path: "/plugins/annotation-qa/workflows/all/quality", Icon: "clipboard-check", Order: 20, GroupID: "annotation-center", GroupLabel: "标注中心", GroupIcon: "tags", RequiredRoles: []string{"admin", "quality_reviewer"}},
|
||||
{ID: "clip", Label: "人工剪切", Path: "/plugins/annotation-qa/workflows/all/clip", Icon: "scissors", Order: 30, GroupID: "annotation-center", GroupLabel: "标注中心", GroupIcon: "tags", RequiredRoles: []string{"admin", "cutter"}},
|
||||
{ID: "clip-quality", Label: "剪切审核", Path: "/plugins/annotation-qa/workflows/all/clip-quality", Icon: "shield-check", Order: 40, GroupID: "annotation-center", GroupLabel: "标注中心", GroupIcon: "tags", RequiredRoles: []string{"admin", "annotator"}},
|
||||
{ID: "acceptance", Label: "最终验收", Path: "/plugins/annotation-qa/workflows/all/acceptance", Icon: "shield-check", Order: 50, GroupID: "annotation-center", GroupLabel: "标注中心", GroupIcon: "tags", RequiredRoles: []string{"admin", "quality_reviewer", "acceptance_reviewer"}},
|
||||
{ID: "annotate", Label: "切分与语义标注", Path: "/plugins/annotation-qa/workflows/all/annotate", Icon: "tags", Order: 10, GroupID: "annotation-center", GroupLabel: "标注中心", GroupIcon: "tags", RequiredRoles: []string{"admin", "annotator"}},
|
||||
{ID: "quality", Label: "切分与标注审核", Path: "/plugins/annotation-qa/workflows/all/quality", Icon: "clipboard-check", Order: 20, GroupID: "annotation-center", GroupLabel: "标注中心", GroupIcon: "tags", RequiredRoles: []string{"admin", "quality_reviewer"}},
|
||||
{ID: "acceptance", Label: "最终验收", Path: "/plugins/annotation-qa/workflows/all/acceptance", Icon: "shield-check", Order: 50, GroupID: "annotation-center", GroupLabel: "标注中心", GroupIcon: "tags", RequiredRoles: []string{"admin", "acceptance_reviewer"}},
|
||||
},
|
||||
WorkflowCapabilities: []string{"human_cut_adjustment", "human_cut_review", "human_annotation", "human_quality_review", "human_acceptance"},
|
||||
OperatorIDs: []string{
|
||||
|
||||
@ -28,10 +28,10 @@ func TestAnnotationManifestContributesWorkbenchesAndOperators(t *testing.T) {
|
||||
if !ok {
|
||||
t.Fatal("annotation plugin manifest is missing")
|
||||
}
|
||||
if len(manifest.Navigation) != 5 {
|
||||
t.Fatalf("expected five navigation contributions, got %#v", manifest.Navigation)
|
||||
if len(manifest.Navigation) != 3 {
|
||||
t.Fatalf("expected three-role navigation contributions, got %#v", manifest.Navigation)
|
||||
}
|
||||
if manifest.Navigation[0].ID != "annotate" || manifest.Navigation[4].ID != "acceptance" {
|
||||
if manifest.Navigation[0].ID != "annotate" || manifest.Navigation[2].ID != "acceptance" {
|
||||
t.Fatalf("unexpected navigation order: %#v", manifest.Navigation)
|
||||
}
|
||||
for _, item := range manifest.Navigation {
|
||||
@ -43,14 +43,8 @@ func TestAnnotationManifestContributesWorkbenchesAndOperators(t *testing.T) {
|
||||
for _, item := range manifest.Navigation {
|
||||
rolesByID[item.ID] = item.RequiredRoles
|
||||
}
|
||||
if len(rolesByID["clip"]) != 2 || rolesByID["clip"][1] != "cutter" {
|
||||
t.Fatalf("cut pool must belong to cutter: %#v", rolesByID["clip"])
|
||||
}
|
||||
if len(rolesByID["clip-quality"]) != 2 || rolesByID["clip-quality"][1] != "annotator" {
|
||||
t.Fatalf("cut review must belong to annotator: %#v", rolesByID["clip-quality"])
|
||||
}
|
||||
if len(rolesByID["acceptance"]) < 2 || rolesByID["acceptance"][1] != "quality_reviewer" {
|
||||
t.Fatalf("final acceptance must belong to reviewer: %#v", rolesByID["acceptance"])
|
||||
if len(rolesByID["acceptance"]) != 2 || rolesByID["acceptance"][1] != "acceptance_reviewer" {
|
||||
t.Fatalf("final acceptance must belong only to the independent acceptance reviewer: %#v", rolesByID["acceptance"])
|
||||
}
|
||||
wanted := map[string]bool{
|
||||
"operator-builtin-annotation-gate": true,
|
||||
|
||||
@ -732,12 +732,12 @@ func fanyuV5PrePackageAcceptanceEvidence(ctx context.Context, runtime *Runtime,
|
||||
if strings.TrimSpace(item.AcceptedByUserID) == "" {
|
||||
return nil, fmt.Errorf("v5 pre-package acceptance has no confirmer identity")
|
||||
}
|
||||
canonical, marshalErr := json.Marshal(map[string]any{"batchId": acceptanceBatch.ID, "itemId": item.ID, "version": item.Version, "acceptedAt": item.AcceptedAt, "confirmedByUserId": item.AcceptedByUserID, "statistics": payload["statistics"], "sourceBatchId": sourceBatch.ID})
|
||||
canonical, marshalErr := json.Marshal(map[string]any{"batchId": acceptanceBatch.ID, "itemId": item.ID, "version": item.Version, "acceptedAt": item.AcceptedAt, "confirmedByUserId": item.AcceptedByUserID, "statistics": payload["statistics"], "poseDelivery": payload["poseDelivery"], "sourceBatchId": sourceBatch.ID})
|
||||
if marshalErr != nil {
|
||||
return nil, marshalErr
|
||||
}
|
||||
digest := sha256.Sum256(canonical)
|
||||
return map[string]any{"confirmed": true, "humanBatchId": acceptanceBatch.ID, "humanItemId": item.ID, "humanItemVersion": item.Version, "acceptedAt": item.AcceptedAt, "confirmedByUserId": item.AcceptedByUserID, "statistics": payload["statistics"], "canonical": string(canonical), "sha256": hex.EncodeToString(digest[:])}, nil
|
||||
return map[string]any{"confirmed": true, "humanBatchId": acceptanceBatch.ID, "humanItemId": item.ID, "humanItemVersion": item.Version, "acceptedAt": item.AcceptedAt, "confirmedByUserId": item.AcceptedByUserID, "statistics": payload["statistics"], "poseDelivery": payload["poseDelivery"], "canonical": string(canonical), "sha256": hex.EncodeToString(digest[:])}, nil
|
||||
}
|
||||
|
||||
func annotationArtifactSize(size int64) string {
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import bisect
|
||||
import csv
|
||||
import json
|
||||
import pathlib
|
||||
import re
|
||||
@ -188,6 +190,8 @@ def _camera_collection_id(value: Any) -> str:
|
||||
def _right_video_artifacts(inputs: list[dict[str, Any]]) -> list[dict[str, Any]]:
|
||||
artifacts: list[dict[str, Any]] = []
|
||||
for artifact in inputs:
|
||||
if str(artifact.get("type", "")).strip().lower() != "video":
|
||||
continue
|
||||
port = str(artifact.get("portId") or artifact.get("portName") or "").strip()
|
||||
data = artifact.get("data") if isinstance(artifact.get("data"), dict) else {}
|
||||
transform_chain = data.get("transformChain") if isinstance(data.get("transformChain"), list) else []
|
||||
@ -246,6 +250,149 @@ def _materialize_input_video(
|
||||
return resolved
|
||||
|
||||
|
||||
def _materialize_input_file(artifact: dict[str, Any], output: pathlib.Path, helpers: HelperMap) -> pathlib.Path:
|
||||
materialize = helpers.get("source_path_from_item")
|
||||
if not callable(materialize):
|
||||
raise RuntimeError("synchronized delivery cannot materialize a sidecar file")
|
||||
source_ref = helpers.get("source_ref_from_artifact")
|
||||
source = source_ref(artifact) if callable(source_ref) else artifact.get("source", {})
|
||||
name = str(artifact.get("name") or "sidecar.bin").strip()
|
||||
resolved = pathlib.Path(materialize({"source": source if isinstance(source, dict) else {}, "path": str(artifact.get("path", ""))}, name, output, {}))
|
||||
if not resolved.is_file() or resolved.stat().st_size <= 0:
|
||||
raise RuntimeError(f"synchronized delivery sidecar is unavailable: {name}")
|
||||
return resolved
|
||||
|
||||
|
||||
def _sidecar_artifacts(inputs: list[dict[str, Any]], ports: set[str]) -> list[dict[str, Any]]:
|
||||
return [artifact for artifact in inputs if str(artifact.get("portId") or artifact.get("portName") or "").strip() in ports]
|
||||
|
||||
|
||||
def _matching_sidecar(collection_id: str, candidates: list[dict[str, Any]], marker: str = "") -> dict[str, Any]:
|
||||
filtered = [item for item in candidates if not marker or marker in str(item.get("name") or "").lower()]
|
||||
matches = [item for item in filtered if _camera_collection_id(item) == collection_id]
|
||||
if len(matches) == 1:
|
||||
return matches[0]
|
||||
if len(filtered) == 1:
|
||||
return filtered[0]
|
||||
if not matches:
|
||||
raise RuntimeError(f"no {marker or 'sidecar'} file matches collection {collection_id}")
|
||||
raise RuntimeError(f"multiple {marker or 'sidecar'} files match collection {collection_id}")
|
||||
|
||||
|
||||
def _clean_csv_cell(value: Any) -> str:
|
||||
return str(value or "").strip().strip("\ufeff").strip("\t").strip()
|
||||
|
||||
|
||||
def _read_rows(path: pathlib.Path) -> tuple[list[str], list[list[str]]]:
|
||||
lines = path.read_text(encoding="utf-8-sig").splitlines()
|
||||
if not lines:
|
||||
raise RuntimeError(f"sidecar CSV is empty: {path.name}")
|
||||
delimiter = "," if "," in lines[0] else "\t"
|
||||
parsed = list(csv.reader(lines, delimiter=delimiter))
|
||||
header = [_clean_csv_cell(value) for value in parsed[0]]
|
||||
rows = [[_clean_csv_cell(value) for value in row] for row in parsed[1:] if any(_clean_csv_cell(value) for value in row)]
|
||||
return header, rows
|
||||
|
||||
|
||||
def _read_pts(path: pathlib.Path) -> list[int]:
|
||||
header, rows = _read_rows(path)
|
||||
normalized = {name.lower(): index for index, name in enumerate(header)}
|
||||
if "timestamp_us" not in normalized:
|
||||
raise RuntimeError(f"PTS CSV must contain timestamp_us: {path.name}")
|
||||
column = normalized["timestamp_us"]
|
||||
values: list[int] = []
|
||||
for row in rows:
|
||||
try:
|
||||
value = int(row[column])
|
||||
except (IndexError, ValueError) as exc:
|
||||
raise RuntimeError(f"PTS CSV contains an invalid timestamp_us: {path.name}") from exc
|
||||
if values and value <= values[-1]:
|
||||
raise RuntimeError(f"PTS CSV timestamp_us must be strictly increasing: {path.name}")
|
||||
values.append(value)
|
||||
if not values:
|
||||
raise RuntimeError(f"PTS CSV has no frame timestamps: {path.name}")
|
||||
return values
|
||||
|
||||
|
||||
def _read_imu(path: pathlib.Path) -> list[dict[str, Any]]:
|
||||
header, rows = _read_rows(path)
|
||||
indexes = {name.lower(): index for index, name in enumerate(header)}
|
||||
required = {"timestamp_us", "x", "y", "z", "type"}
|
||||
if not required.issubset(indexes):
|
||||
raise RuntimeError(f"IMU CSV must contain timestamp_us,x,y,z,type: {path.name}")
|
||||
result: list[dict[str, Any]] = []
|
||||
previous = -1
|
||||
for row in rows:
|
||||
try:
|
||||
timestamp = int(row[indexes["timestamp_us"]])
|
||||
kind = row[indexes["type"]].lower()
|
||||
values = [float(row[indexes[key]]) for key in ("x", "y", "z")]
|
||||
except (IndexError, ValueError) as exc:
|
||||
raise RuntimeError(f"IMU CSV contains an invalid row: {path.name}") from exc
|
||||
if kind not in {"accel", "gyro"} or timestamp < previous:
|
||||
raise RuntimeError(f"IMU CSV type/timestamp ordering is invalid: {path.name}")
|
||||
previous = timestamp
|
||||
result.append({"timestamp_us": timestamp, "x": values[0], "y": values[1], "z": values[2], "type": kind})
|
||||
if not result:
|
||||
raise RuntimeError(f"IMU CSV has no samples: {path.name}")
|
||||
return result
|
||||
|
||||
|
||||
def _ffprobe_frame_count(path: pathlib.Path) -> int:
|
||||
completed = subprocess.run(["ffprobe", "-v", "error", "-select_streams", "v:0", "-count_frames", "-show_entries", "stream=nb_read_frames", "-of", "default=nokey=1:noprint_wrappers=1", str(path)], capture_output=True, text=True, check=False)
|
||||
try:
|
||||
count = int(completed.stdout.strip())
|
||||
except ValueError as exc:
|
||||
raise RuntimeError(f"cannot determine decoded video frame count: {path.name}") from exc
|
||||
if completed.returncode != 0 or count <= 0:
|
||||
raise RuntimeError(f"cannot determine decoded video frame count: {path.name}")
|
||||
return count
|
||||
|
||||
|
||||
def _write_frame_segment(source: pathlib.Path, destination: pathlib.Path, start_frame: int, end_frame: int) -> None:
|
||||
if shutil.which("ffmpeg") is None or shutil.which("ffprobe") is None:
|
||||
raise RuntimeError("synchronized delivery requires ffmpeg and ffprobe")
|
||||
if start_frame < 0 or end_frame <= start_frame:
|
||||
raise RuntimeError("synchronized video frame range is empty")
|
||||
destination.parent.mkdir(parents=True, exist_ok=True)
|
||||
expression = f"trim=start_frame={start_frame}:end_frame={end_frame},setpts=PTS-STARTPTS"
|
||||
completed = subprocess.run(["ffmpeg", "-nostdin", "-hide_banner", "-loglevel", "error", "-y", "-i", str(source), "-an", "-vf", expression, "-c:v", "libx264", "-preset", "veryfast", "-crf", "23", "-pix_fmt", "yuv420p", "-movflags", "+faststart", str(destination)], capture_output=True, text=True, check=False)
|
||||
if completed.returncode != 0 or not destination.is_file() or destination.stat().st_size <= 0:
|
||||
raise RuntimeError(f"synchronized frame-accurate cut failed: {(completed.stderr or completed.stdout).strip()[:800]}")
|
||||
|
||||
|
||||
def _write_pts_slice(path: pathlib.Path, timestamps: list[int], start_index: int, end_index: int) -> dict[str, Any]:
|
||||
selected = timestamps[start_index:end_index]
|
||||
if not selected:
|
||||
raise RuntimeError("synchronized PTS slice is empty")
|
||||
with path.open("w", encoding="utf-8", newline="") as handle:
|
||||
writer = csv.writer(handle)
|
||||
writer.writerow(["frame_index", "timestamp_ms", "clip_time_ms"])
|
||||
origin = selected[0]
|
||||
for index, value in enumerate(selected):
|
||||
writer.writerow([index, round(value / 1000), round((value - origin) / 1000)])
|
||||
return {"name": path.name, "sha256": _sha256_file(path), "bytes": path.stat().st_size, "rowCount": len(selected), "firstTimestampUs": selected[0], "lastTimestampUs": selected[-1]}
|
||||
|
||||
|
||||
def _write_imu_slice(path: pathlib.Path, rows: list[dict[str, Any]], start_us: int, end_us: int) -> dict[str, Any]:
|
||||
selected = [row for row in rows if start_us <= int(row["timestamp_us"]) < end_us]
|
||||
if not selected:
|
||||
raise RuntimeError("synchronized IMU slice is empty")
|
||||
by_timestamp: dict[int, set[str]] = {}
|
||||
for row in selected:
|
||||
by_timestamp.setdefault(int(row["timestamp_us"]), set()).add(str(row["type"]))
|
||||
if any(types != {"accel", "gyro"} for types in by_timestamp.values()):
|
||||
raise RuntimeError("synchronized IMU slice contains an unpaired accel/gyro timestamp")
|
||||
with path.open("w", encoding="utf-8", newline="") as handle:
|
||||
writer = csv.writer(handle)
|
||||
writer.writerow(["timestamp_ms", "clip_time_ms", "x", "y", "z", "type"])
|
||||
origin = int(selected[0]["timestamp_us"])
|
||||
for row in selected:
|
||||
timestamp = int(row["timestamp_us"])
|
||||
writer.writerow([round(timestamp / 1000), round((timestamp - origin) / 1000), row["x"], row["y"], row["z"], row["type"]])
|
||||
return {"name": path.name, "sha256": _sha256_file(path), "bytes": path.stat().st_size, "sampleCount": len(selected), "timestampCount": len(by_timestamp), "firstTimestampUs": int(selected[0]["timestamp_us"]), "lastTimestampUs": int(selected[-1]["timestamp_us"])}
|
||||
|
||||
|
||||
def _write_verified_segment(
|
||||
source: pathlib.Path,
|
||||
destination: pathlib.Path,
|
||||
@ -269,7 +416,7 @@ def _write_verified_segment(
|
||||
}
|
||||
|
||||
|
||||
def _validate_final_acceptance(item: dict[str, Any]) -> None:
|
||||
def _validate_final_acceptance(item: dict[str, Any]) -> dict[str, Any]:
|
||||
evidence = item.get("finalAcceptance") if isinstance(item.get("finalAcceptance"), dict) else {}
|
||||
canonical = str(evidence.get("canonical", ""))
|
||||
digest = str(evidence.get("sha256", "")).lower()
|
||||
@ -279,6 +426,7 @@ def _validate_final_acceptance(item: dict[str, Any]) -> None:
|
||||
raise RuntimeError("pre-package acceptance evidence SHA-256 does not verify")
|
||||
if not str(evidence.get("confirmedByUserId", "")).strip():
|
||||
raise RuntimeError("pre-package acceptance evidence has no confirmer identity")
|
||||
return evidence
|
||||
|
||||
|
||||
def _write_precise_final_segment(source: pathlib.Path, destination: pathlib.Path, start: float, end: float) -> None:
|
||||
@ -357,6 +505,23 @@ def _materialize_final_mp4(item: dict[str, Any], package_dir: pathlib.Path, help
|
||||
return destination
|
||||
|
||||
|
||||
def _materialize_left_source(item: dict[str, Any], directory: pathlib.Path, helpers: HelperMap) -> pathlib.Path:
|
||||
source_path = pathlib.Path(str(item.get("clipPath", "")).strip())
|
||||
if source_path.is_file() and source_path.stat().st_size > 0:
|
||||
return source_path
|
||||
source = item.get("source") if isinstance(item.get("source"), dict) else {}
|
||||
resolved = pathlib.Path(
|
||||
helpers["source_path_from_item"](
|
||||
{"source": source or {"path": str(item.get("clipPath", "")).strip()}},
|
||||
str(item.get("sourceVideo") or pathlib.PurePosixPath(str(item.get("clipPath", ""))).name or "left-camera.mp4"),
|
||||
directory,
|
||||
)
|
||||
)
|
||||
if not resolved.is_file() or resolved.stat().st_size <= 0:
|
||||
raise RuntimeError("left-camera video is unavailable for synchronized cropping")
|
||||
return resolved
|
||||
|
||||
|
||||
def _collect_unique_package_artifacts(
|
||||
run_id: str,
|
||||
node_id: str,
|
||||
@ -382,6 +547,90 @@ def _collect_unique_package_artifacts(
|
||||
return artifacts
|
||||
|
||||
|
||||
def _copy_calibrations(inputs: list[dict[str, Any]], packages_root: pathlib.Path, output: pathlib.Path, helpers: HelperMap) -> list[dict[str, Any]]:
|
||||
destination = packages_root / "calibration"
|
||||
result: list[dict[str, Any]] = []
|
||||
seen: set[str] = set()
|
||||
for artifact in _sidecar_artifacts(inputs, {"calibrations"}):
|
||||
name = str(artifact.get("name") or "").strip()
|
||||
if not name or name in seen:
|
||||
continue
|
||||
seen.add(name)
|
||||
source = _materialize_input_file(artifact, output / "_inputs", helpers)
|
||||
destination.mkdir(parents=True, exist_ok=True)
|
||||
target = destination / name
|
||||
shutil.copy2(source, target)
|
||||
result.append({"name": name, "path": f"calibration/{name}", "sha256": _sha256_file(target), "bytes": target.stat().st_size})
|
||||
if not result:
|
||||
raise RuntimeError("synchronized delivery requires camera/IMU calibration files")
|
||||
return result
|
||||
|
||||
|
||||
def _synchronized_segment(
|
||||
item: dict[str, Any],
|
||||
clip_id: str,
|
||||
package_dir: pathlib.Path,
|
||||
output: pathlib.Path,
|
||||
start: float,
|
||||
end: float,
|
||||
inputs: list[dict[str, Any]],
|
||||
right_videos: list[dict[str, Any]],
|
||||
helpers: HelperMap,
|
||||
) -> tuple[pathlib.Path, dict[str, Any], dict[str, Any]]:
|
||||
collection_id = str(item.get("collectionId") or "").strip() or _camera_collection_id(_source_video_name(item))
|
||||
left_pts_artifact = _matching_sidecar(collection_id, _sidecar_artifacts(inputs, {"leftTimestamps"}), "left")
|
||||
right_pts_artifact = _matching_sidecar(collection_id, _sidecar_artifacts(inputs, {"rightTimestamps"}), "right")
|
||||
imu_artifact = _matching_sidecar(collection_id, _sidecar_artifacts(inputs, {"imu"}), "imu")
|
||||
left_pts_path = _materialize_input_file(left_pts_artifact, output / "_inputs", helpers)
|
||||
right_pts_path = _materialize_input_file(right_pts_artifact, output / "_inputs", helpers)
|
||||
imu_path = _materialize_input_file(imu_artifact, output / "_inputs", helpers)
|
||||
left_pts = _read_pts(left_pts_path)
|
||||
right_pts = _read_pts(right_pts_path)
|
||||
imu_rows = _read_imu(imu_path)
|
||||
left_source = _materialize_left_source(item, output / "_inputs", helpers)
|
||||
right_artifact = _matching_right_video(item, right_videos)
|
||||
if right_artifact is None:
|
||||
raise RuntimeError(f"accepted segment {clip_id} has no matching right-camera video")
|
||||
right_source = _materialize_input_video(right_artifact, output / "_inputs", helpers)
|
||||
if _ffprobe_frame_count(left_source) != len(left_pts):
|
||||
raise RuntimeError("left-camera decoded frame count does not match left PTS rows")
|
||||
if _ffprobe_frame_count(right_source) != len(right_pts):
|
||||
raise RuntimeError("right-camera decoded frame count does not match right PTS rows")
|
||||
target_start_us = left_pts[0] + round(start * 1_000_000)
|
||||
target_end_us = left_pts[0] + round(end * 1_000_000)
|
||||
imu_first, imu_last = int(imu_rows[0]["timestamp_us"]), int(imu_rows[-1]["timestamp_us"])
|
||||
common_start = max(left_pts[0], right_pts[0], imu_first)
|
||||
common_end = min(left_pts[-1], right_pts[-1], imu_last)
|
||||
if target_start_us < common_start or target_end_us > common_end or target_end_us <= target_start_us:
|
||||
raise RuntimeError("final segment is outside the common left/right/IMU hardware timestamp range")
|
||||
left_start, left_end = bisect.bisect_left(left_pts, target_start_us), bisect.bisect_left(left_pts, target_end_us)
|
||||
right_start, right_end = bisect.bisect_left(right_pts, target_start_us), bisect.bisect_left(right_pts, target_end_us)
|
||||
left_destination = package_dir / str(item.get("clipName") or f"{clip_id}_left.mp4")
|
||||
right_destination = package_dir / f"{clip_id}_right.mp4"
|
||||
_write_frame_segment(left_source, left_destination, left_start, left_end)
|
||||
_write_frame_segment(right_source, right_destination, right_start, right_end)
|
||||
if _ffprobe_frame_count(left_destination) != left_end - left_start or _ffprobe_frame_count(right_destination) != right_end - right_start:
|
||||
raise RuntimeError("synchronized output frame count does not match sliced PTS rows")
|
||||
left_pts_manifest = _write_pts_slice(package_dir / f"{clip_id}_left_pts.csv", left_pts, left_start, left_end)
|
||||
right_pts_manifest = _write_pts_slice(package_dir / f"{clip_id}_right_pts.csv", right_pts, right_start, right_end)
|
||||
imu_manifest = _write_imu_slice(package_dir / f"{clip_id}_imu.csv", imu_rows, target_start_us, target_end_us)
|
||||
left_video = {"name": left_destination.name, "sha256": _sha256_file(left_destination), "bytes": left_destination.stat().st_size, "cameraSide": "left", "frameCount": left_end - left_start}
|
||||
right_video = {"name": right_destination.name, "sha256": _sha256_file(right_destination), "bytes": right_destination.stat().st_size, "cameraSide": "right", "frameCount": right_end - right_start, "sourceVideo": str(right_artifact.get("name") or right_source.name)}
|
||||
alignment_values = [left_pts[left_start], right_pts[right_start], int(imu_manifest["firstTimestampUs"]), left_pts[left_end - 1], right_pts[right_end - 1], int(imu_manifest["lastTimestampUs"])]
|
||||
max_alignment_error_us = max(abs(value - target_start_us) for value in alignment_values[:3])
|
||||
synchronized = {
|
||||
"schemaVersion": "droboticflow.synchronized-slice/v1",
|
||||
"collectionId": collection_id,
|
||||
"window": {"startTimestampUs": target_start_us, "endTimestampUs": target_end_us, "semantics": "half-open"},
|
||||
"commonRange": {"startTimestampUs": common_start, "endTimestampUs": common_end},
|
||||
"left": {"video": left_video, "pts": left_pts_manifest},
|
||||
"right": {"video": right_video, "pts": right_pts_manifest},
|
||||
"imu": imu_manifest,
|
||||
"maxStartAlignmentErrorUs": max_alignment_error_us,
|
||||
}
|
||||
return left_destination, right_video, synchronized
|
||||
|
||||
|
||||
def _run_fanyu_v5(run_id: str, node_id: str, output_dir: Any, node_data: dict[str, Any], inputs: list[dict[str, Any]], helpers: HelperMap) -> list[dict[str, Any]]:
|
||||
output = pathlib.Path(output_dir)
|
||||
output.mkdir(parents=True, exist_ok=True)
|
||||
@ -392,14 +641,16 @@ def _run_fanyu_v5(run_id: str, node_id: str, output_dir: Any, node_data: dict[st
|
||||
pose_free = _bool(params, "POSE_FREE", False)
|
||||
require_final_acceptance = _bool(params, "REQUIRE_FINAL_ACCEPTANCE", False)
|
||||
generate_segment_mp4 = _bool(params, "GENERATE_SEGMENT_MP4", False)
|
||||
synchronized_sidecars = _bool(params, "SYNCHRONIZED_SIDECARS", False)
|
||||
allow_pose_exclusion = _bool(params, "ALLOW_POSE_EXCLUSION", False)
|
||||
payloads = _payload_tree(_payloads_with_full_pose_manifests(inputs, output, helpers))
|
||||
headpose = _first_payload(payloads, "droboticflow.headpose/v1")
|
||||
handpose = _first_payload(payloads, "droboticflow.wilor.hand_pose_result/v1")
|
||||
if pose_free and (headpose is not None or handpose is not None):
|
||||
raise RuntimeError("pose-free v5 package rejects HeadPose and HandPose payloads")
|
||||
if require_headpose and (headpose is None or not headpose.get("enabled") or not isinstance(headpose.get("frames"), list)):
|
||||
if require_headpose and not allow_pose_exclusion and (headpose is None or not headpose.get("enabled") or not isinstance(headpose.get("frames"), list)):
|
||||
raise RuntimeError("package requires a real Headpose manifest with frames")
|
||||
if require_handpose and (
|
||||
if require_handpose and not allow_pose_exclusion and (
|
||||
handpose is None
|
||||
or handpose.get("enabled") is False
|
||||
or not _pose_frames(handpose, "handpose")
|
||||
@ -427,9 +678,22 @@ def _run_fanyu_v5(run_id: str, node_id: str, output_dir: Any, node_data: dict[st
|
||||
raise RuntimeError("stereo delivery has no accepted Qwen clip with a camera collection")
|
||||
package_items: list[dict[str, Any]] = []
|
||||
binding = helpers["output_binding"](node_data)
|
||||
calibration_refs = _copy_calibrations(inputs, output / "packages", output, helpers) if synchronized_sidecars else []
|
||||
package_pose_policy: dict[str, Any] | None = None
|
||||
for index, item in enumerate(accepted_items):
|
||||
acceptance_evidence: dict[str, Any] = {}
|
||||
if require_final_acceptance:
|
||||
_validate_final_acceptance(item)
|
||||
acceptance_evidence = _validate_final_acceptance(item)
|
||||
pose_policy = acceptance_evidence.get("poseDelivery") if isinstance(acceptance_evidence.get("poseDelivery"), dict) else {}
|
||||
if allow_pose_exclusion:
|
||||
if pose_policy.get("headpose") not in {"include", "exclude"} or pose_policy.get("handpose") not in {"include", "exclude"}:
|
||||
raise RuntimeError("v5.8 final acceptance must decide HeadPose and HandPose inclusion")
|
||||
if package_pose_policy is None:
|
||||
package_pose_policy = pose_policy
|
||||
elif package_pose_policy != pose_policy:
|
||||
raise RuntimeError("v5.8 package items contain conflicting aggregate pose delivery decisions")
|
||||
include_headpose = not allow_pose_exclusion or pose_policy.get("headpose") == "include"
|
||||
include_handpose = not allow_pose_exclusion or pose_policy.get("handpose") == "include"
|
||||
clip_id = str(item.get("clipId") or f"segment-{index + 1:04d}").strip()
|
||||
package_dir = output / "packages" / f"{clip_id}_package"
|
||||
package_dir.mkdir(parents=True, exist_ok=True)
|
||||
@ -439,7 +703,11 @@ def _run_fanyu_v5(run_id: str, node_id: str, output_dir: Any, node_data: dict[st
|
||||
raise RuntimeError("accepted package item has invalid final source boundaries")
|
||||
# 虚拟切片条目没有物理中间片段:无论是否显式要求 MP4,
|
||||
# 都必须按源视频区间在打包阶段精确物化最终交付 MP4。
|
||||
if generate_segment_mp4 or item.get("finalSegment") is True or item.get("virtualCut") is True:
|
||||
synchronized_manifest = None
|
||||
right_video_manifest = None
|
||||
if synchronized_sidecars:
|
||||
video_path, right_video_manifest, synchronized_manifest = _synchronized_segment(item, clip_id, package_dir, output, start, end, inputs, right_videos, helpers)
|
||||
elif generate_segment_mp4 or item.get("finalSegment") is True or item.get("virtualCut") is True:
|
||||
video_path = _materialize_final_mp4(item, package_dir, helpers)
|
||||
else:
|
||||
source = pathlib.Path(str(item.get("clipPath", "")).strip())
|
||||
@ -448,15 +716,14 @@ def _run_fanyu_v5(run_id: str, node_id: str, output_dir: Any, node_data: dict[st
|
||||
video_path = package_dir / (str(item.get("clipName") or source.name))
|
||||
shutil.copy2(source, video_path)
|
||||
annotation = item.get("annotation") if isinstance(item.get("annotation"), dict) else {}
|
||||
headpose_segment = _crop_pose(headpose, start, end, "headpose") if headpose else None
|
||||
handpose_segment = _crop_pose(handpose, start, end, "handpose") if handpose and handpose.get("enabled", True) else None
|
||||
if require_headpose and (headpose_segment is None or headpose_segment["frameCount"] <= 0):
|
||||
headpose_segment = _crop_pose(headpose, start, end, "headpose") if include_headpose and headpose else None
|
||||
handpose_segment = _crop_pose(handpose, start, end, "handpose") if include_handpose and handpose and handpose.get("enabled", True) else None
|
||||
if require_headpose and include_headpose and (headpose_segment is None or headpose_segment["frameCount"] <= 0):
|
||||
raise RuntimeError("required Headpose has no frame inside the final half-open segment interval")
|
||||
if require_handpose and (handpose_segment is None or handpose_segment["frameCount"] <= 0):
|
||||
if require_handpose and include_handpose and (handpose_segment is None or handpose_segment["frameCount"] <= 0):
|
||||
raise RuntimeError("required HandPose has no frame inside the final half-open segment interval")
|
||||
right_video = _matching_right_video(item, right_videos)
|
||||
right_video_manifest = None
|
||||
if right_video is not None:
|
||||
right_video = None if synchronized_sidecars else _matching_right_video(item, right_videos)
|
||||
if not synchronized_sidecars and right_video is not None:
|
||||
right_source = _materialize_input_video(right_video, output, helpers)
|
||||
right_destination = package_dir / f"{clip_id}_right.mp4"
|
||||
right_video_manifest = _write_verified_segment(right_source, right_destination, start, end, helpers)
|
||||
@ -466,9 +733,12 @@ def _run_fanyu_v5(run_id: str, node_id: str, output_dir: Any, node_data: dict[st
|
||||
right_video_manifest["transformChain"] = (
|
||||
right_data.get("transformChain") if isinstance(right_data.get("transformChain"), list) else []
|
||||
)
|
||||
elif require_stereo_delivery:
|
||||
elif not synchronized_sidecars and require_stereo_delivery:
|
||||
raise RuntimeError(f"accepted segment {clip_id} has no matching right-camera video")
|
||||
helpers["write_json_artifact"](run_id, node_id, package_dir, "semantic.json", annotation, output=binding)
|
||||
if synchronized_manifest is not None:
|
||||
synchronized_manifest["calibration"] = calibration_refs
|
||||
helpers["write_json_artifact"](run_id, node_id, package_dir, "synchronized-slice.json", synchronized_manifest, output=binding)
|
||||
segment_manifest = {
|
||||
"schemaVersion": "droboticflow.delivery.segment/v2",
|
||||
"clipId": clip_id,
|
||||
@ -478,6 +748,9 @@ def _run_fanyu_v5(run_id: str, node_id: str, output_dir: Any, node_data: dict[st
|
||||
"semantic": {"file": "semantic.json", "actionCount": len(annotation.get("actions", []))},
|
||||
"transformChain": item.get("transformChain", []) if isinstance(item.get("transformChain"), list) else [],
|
||||
"finalAcceptance": item.get("finalAcceptance") if require_final_acceptance else None,
|
||||
"poseDelivery": pose_policy if allow_pose_exclusion else None,
|
||||
"synchronizedSlice": {"file": "synchronized-slice.json", "schemaVersion": "droboticflow.synchronized-slice/v1"} if synchronized_manifest is not None else None,
|
||||
"calibration": calibration_refs,
|
||||
}
|
||||
segment_manifest["videos"] = {
|
||||
"left": {**segment_manifest["video"], "cameraSide": "left"},
|
||||
@ -495,7 +768,7 @@ def _run_fanyu_v5(run_id: str, node_id: str, output_dir: Any, node_data: dict[st
|
||||
package_items.append({"packageName": package_dir.name, "clipId": clip_id, "clipName": video_path.name, "rightClipName": right_video_manifest["name"] if right_video_manifest else "", "sourceVideo": source_video, "sourceRightVideo": right_video_manifest["sourceVideo"] if right_video_manifest else "", "stereo": right_video_manifest is not None, "storagePath": str(package_dir), "startSecond": start, "endSecond": end, "clipDuration": end - start, "duration": end - start, "fileCount": len([path for path in package_dir.iterdir() if path.is_file()]), "quality": quality, "annotation": annotation, "segmentManifest": segment_manifest})
|
||||
if not package_items:
|
||||
raise RuntimeError("package produced zero final segment packages")
|
||||
manifest = {"schemaVersion": "droboticflow.delivery.manifest/v3", "datasetType": "fanyu-v5-final-segments", "packageCount": len(package_items), "stereoDelivery": all(item["stereo"] for item in package_items), "headposeIncluded": headpose is not None, "handposeIncluded": handpose is not None and handpose.get("enabled", True), "items": package_items, "trainingEnabled": False}
|
||||
manifest = {"schemaVersion": "droboticflow.delivery.manifest/v4" if synchronized_sidecars else "droboticflow.delivery.manifest/v3", "datasetType": "fanyu-v5-final-segments", "packageCount": len(package_items), "stereoDelivery": all(item["stereo"] for item in package_items), "headposeIncluded": headpose is not None and (not allow_pose_exclusion or (package_pose_policy or {}).get("headpose") == "include"), "handposeIncluded": handpose is not None and handpose.get("enabled", True) and (not allow_pose_exclusion or (package_pose_policy or {}).get("handpose") == "include"), "poseDelivery": package_pose_policy, "audioIncluded": False if synchronized_sidecars else None, "calibration": calibration_refs, "items": package_items, "trainingEnabled": False}
|
||||
artifacts = [helpers["write_json_artifact"](run_id, node_id, output, "packages-manifest.json", manifest, output=binding)]
|
||||
artifacts.extend(_collect_unique_package_artifacts(run_id, node_id, output / "packages", node_data, binding, helpers))
|
||||
return artifacts
|
||||
|
||||
@ -111,7 +111,7 @@ function RoleRouteGuard({ children }: { children: React.ReactNode }) {
|
||||
currentUser?.role === "data_operator"
|
||||
? "annotator"
|
||||
: currentUser?.role === "acceptance_reviewer"
|
||||
? "quality_reviewer"
|
||||
? "acceptance_reviewer"
|
||||
: currentUser?.role === "qa_reviewer" ||
|
||||
currentUser?.role === "auditor" ||
|
||||
currentUser?.role === "compliance_auditor"
|
||||
@ -144,6 +144,13 @@ function RoleRouteGuard({ children }: { children: React.ReactNode }) {
|
||||
if (effectiveRole === "quality_reviewer" && !qualityPath && !itemPath) {
|
||||
return <Navigate to="/plugins/annotation-qa/workflows/all/quality" replace />;
|
||||
}
|
||||
if (
|
||||
effectiveRole === "acceptance_reviewer" &&
|
||||
!(path.includes("/plugins/annotation-qa/workflows/") && path.endsWith("/acceptance")) &&
|
||||
!itemPath
|
||||
) {
|
||||
return <Navigate to="/plugins/annotation-qa/workflows/all/acceptance" replace />;
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
export function resolvePluginNavigationRole(role) {
|
||||
if (role === "data_operator") return "annotator";
|
||||
if (role === "acceptance_reviewer") return "quality_reviewer";
|
||||
if (role === "acceptance_reviewer") return "acceptance_reviewer";
|
||||
if (role === "qa_reviewer" || role === "auditor" || role === "compliance_auditor") {
|
||||
return "quality_reviewer";
|
||||
}
|
||||
|
||||
@ -12,23 +12,23 @@ export const USER_ROLE_OPTIONS: Array<{
|
||||
},
|
||||
{
|
||||
value: "cutter",
|
||||
label: "人工剪切员",
|
||||
description: "领取人工剪切任务,调整或重做自动粗切片段",
|
||||
label: "旧版剪切员(兼容)",
|
||||
description: "仅用于历史 v5.7 任务;新流程不再创建该角色",
|
||||
},
|
||||
{
|
||||
value: "annotator",
|
||||
label: "标注员",
|
||||
description: "领取剪切审核与语义标注任务,可将不可用片段打回剪切池",
|
||||
description: "在同一任务中完成真实切分校正和语义标注",
|
||||
},
|
||||
{
|
||||
value: "quality_reviewer",
|
||||
label: "审核员",
|
||||
description: "领取标注审核与最终验收任务,统一负责质量结论",
|
||||
description: "独立审核切分边界、左右目对应关系和语义标注",
|
||||
},
|
||||
{
|
||||
value: "acceptance_reviewer",
|
||||
label: "旧版验收员(兼容)",
|
||||
description: "兼容历史账号,按审核员权限访问标注审核与最终验收",
|
||||
label: "最终验收员",
|
||||
description: "独立领取整包最终验收任务,不参与标注审核",
|
||||
},
|
||||
{
|
||||
value: "supplier_manager",
|
||||
|
||||
@ -31,7 +31,7 @@ export function canAccessWorkflowCapability(role, capabilityId) {
|
||||
return ["quality_reviewer", "qa_reviewer", "auditor"].includes(role);
|
||||
}
|
||||
if (capabilityId === "human_acceptance") {
|
||||
return ["quality_reviewer", "acceptance_reviewer", "qa_reviewer", "auditor"].includes(role);
|
||||
return role === "acceptance_reviewer";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -93,6 +93,9 @@ const emptyPrepackageAcceptanceStatistics = {
|
||||
annotationAccuracy: "",
|
||||
annotationCompleteness: "",
|
||||
overallGrade: "",
|
||||
headpose: "include" as "include" | "exclude",
|
||||
handpose: "include" as "include" | "exclude",
|
||||
exclusionReason: "",
|
||||
};
|
||||
|
||||
type PrepackageAcceptanceStatistics = typeof emptyPrepackageAcceptanceStatistics;
|
||||
@ -114,6 +117,16 @@ function prepackageAcceptanceStatisticsAreValid(statistics: PrepackageAcceptance
|
||||
);
|
||||
}
|
||||
|
||||
function strictAcceptanceDraftIsValid(statistics: PrepackageAcceptanceStatistics) {
|
||||
return (
|
||||
["include", "exclude"].includes(statistics.headpose) &&
|
||||
["include", "exclude"].includes(statistics.handpose) &&
|
||||
(statistics.headpose === "include" && statistics.handpose === "include"
|
||||
? true
|
||||
: statistics.exclusionReason.trim() !== "")
|
||||
);
|
||||
}
|
||||
|
||||
function deliveryArtifactPreviewURL(item: ExecutionData | undefined) {
|
||||
const preview = item?.data?.preview;
|
||||
if (preview && typeof preview === "object" && typeof preview.url === "string") return preview.url;
|
||||
@ -185,7 +198,8 @@ function taskVisibleInMode(task: AnnotationTaskRecord, mode: WorkspaceMode) {
|
||||
if (mode === "clip") return task.humanStageId === "split_annotation" || task.humanStageId === "cut_adjustment";
|
||||
if (mode === "clip-quality")
|
||||
return task.humanStageId === "split_quality_review" || task.humanStageId === "cut_review";
|
||||
if (mode === "annotate") return task.humanStageId === "semantic_annotation";
|
||||
if (mode === "annotate")
|
||||
return task.humanStageId === "semantic_annotation" || task.humanStageId === "annotation_combined";
|
||||
if (mode === "quality") return task.humanStageId === "quality_review" || task.humanStageId === "semantic_review";
|
||||
}
|
||||
if (mode === "clip") {
|
||||
@ -234,6 +248,7 @@ function assignmentRoleForStage(stageId: string): ProjectAnnotationMembership["a
|
||||
) {
|
||||
return "annotator";
|
||||
}
|
||||
if (stageId === "acceptance" || stageId === "prepackage_acceptance") return "acceptance_reviewer";
|
||||
return "quality_reviewer";
|
||||
}
|
||||
|
||||
@ -241,18 +256,14 @@ function assignmentRoleMatches(
|
||||
actual: ProjectAnnotationMembership["assignmentRole"],
|
||||
required: ProjectAnnotationMembership["assignmentRole"],
|
||||
) {
|
||||
return (
|
||||
actual === required ||
|
||||
(required === "quality_reviewer" && actual === "acceptance_reviewer") ||
|
||||
(required === "acceptance_reviewer" && actual === "quality_reviewer")
|
||||
);
|
||||
return actual === required;
|
||||
}
|
||||
|
||||
function assignmentRoleLabel(role: ProjectAnnotationMembership["assignmentRole"]) {
|
||||
if (role === "cutter") return "人工剪切员";
|
||||
if (role === "annotator") return "标注员";
|
||||
if (role === "quality_reviewer") return "审核员";
|
||||
if (role === "acceptance_reviewer") return "旧版验收员";
|
||||
if (role === "acceptance_reviewer") return "最终验收员";
|
||||
return "供应商管理员";
|
||||
}
|
||||
|
||||
@ -649,20 +660,20 @@ export default function AnnotationOperations() {
|
||||
: workspaceMode === "clip-quality"
|
||||
? "剪切审核"
|
||||
: workspaceMode === "quality"
|
||||
? "标注审核"
|
||||
? "切分与标注审核"
|
||||
: workspaceMode === "acceptance"
|
||||
? "最终验收"
|
||||
: "语义标注";
|
||||
: "真实切分与语义标注";
|
||||
const queueTabLabel =
|
||||
workspaceMode === "clip"
|
||||
? "调切队列"
|
||||
: workspaceMode === "clip-quality"
|
||||
? "剪切审核队列"
|
||||
: workspaceMode === "quality"
|
||||
? "标注审核队列"
|
||||
? "切分与标注审核队列"
|
||||
: workspaceMode === "acceptance"
|
||||
? "验收队列"
|
||||
: "标注队列";
|
||||
: "切分与标注队列";
|
||||
|
||||
const addSegment = () => {
|
||||
if (!detail) return;
|
||||
@ -1159,28 +1170,60 @@ export default function AnnotationOperations() {
|
||||
}
|
||||
};
|
||||
|
||||
const confirmPrepackageAcceptance = async (item: HumanItem, statistics: PrepackageAcceptanceStatistics) => {
|
||||
if (!prepackageAcceptanceStatisticsAreValid(statistics)) {
|
||||
const decidePrepackageAcceptance = async (
|
||||
item: HumanItem,
|
||||
statistics: PrepackageAcceptanceStatistics,
|
||||
decision: "approved" | "rejected",
|
||||
strictThreeRole: boolean,
|
||||
) => {
|
||||
if (decision === "approved" && strictThreeRole && !strictAcceptanceDraftIsValid(statistics)) {
|
||||
setError("排除 HeadPose 或 HandPose 时必须填写原因。");
|
||||
return;
|
||||
}
|
||||
if (decision === "approved" && !strictThreeRole && !prepackageAcceptanceStatisticsAreValid(statistics)) {
|
||||
setError("请填写视频质量、总体等级,以及 0–100 的标注准确性和完整性后再确认。");
|
||||
return;
|
||||
}
|
||||
if (decision === "rejected" && !reviewComment.trim()) {
|
||||
setError("整包验收不通过必须填写问题说明。");
|
||||
return;
|
||||
}
|
||||
setSaving(true);
|
||||
setError("");
|
||||
try {
|
||||
await humanLoopApi.decide(item.id, {
|
||||
version: item.version,
|
||||
decision: "approved",
|
||||
decision,
|
||||
reviewedRevision: item.currentRevision,
|
||||
comment: reviewComment.trim(),
|
||||
videoQuality: statistics.videoQuality,
|
||||
annotationAccuracy: Number(statistics.annotationAccuracy),
|
||||
annotationCompleteness: Number(statistics.annotationCompleteness),
|
||||
overallGrade: statistics.overallGrade,
|
||||
comment: reviewComment.trim() || statistics.exclusionReason.trim(),
|
||||
reasonCodes:
|
||||
decision === "rejected"
|
||||
? ["batch_acceptance_rejected"]
|
||||
: statistics.headpose === "exclude" || statistics.handpose === "exclude"
|
||||
? ["pose_excluded"]
|
||||
: undefined,
|
||||
videoQuality: strictThreeRole ? undefined : statistics.videoQuality,
|
||||
annotationAccuracy: strictThreeRole ? undefined : Number(statistics.annotationAccuracy),
|
||||
annotationCompleteness: strictThreeRole ? undefined : Number(statistics.annotationCompleteness),
|
||||
overallGrade: strictThreeRole ? undefined : statistics.overallGrade,
|
||||
poseDelivery: strictThreeRole
|
||||
? {
|
||||
headpose: statistics.headpose,
|
||||
handpose: statistics.handpose,
|
||||
reasonCodes:
|
||||
statistics.headpose === "exclude" || statistics.handpose === "exclude" ? ["pose_excluded"] : undefined,
|
||||
}
|
||||
: undefined,
|
||||
});
|
||||
setReviewComment("");
|
||||
await loadProject();
|
||||
} catch (confirmError) {
|
||||
setError(getActionErrorMessage(confirmError, "确认最终验收失败;下游打包未释放"));
|
||||
setError(
|
||||
getActionErrorMessage(
|
||||
confirmError,
|
||||
decision === "rejected" ? "整包打回失败" : "确认最终验收失败;下游打包未释放",
|
||||
),
|
||||
);
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
@ -1319,17 +1362,18 @@ export default function AnnotationOperations() {
|
||||
const selectedClipArtifactId = String(selectedEvidence?.clipArtifactId || "");
|
||||
const claimedByMe = item.assignedUserId === currentUser?.id;
|
||||
const acceptanceStatistics = prepackageAcceptanceDrafts[item.id] || emptyPrepackageAcceptanceStatistics;
|
||||
const strictThreeRole = payload.strictThreeRole === true;
|
||||
const acceptanceAssignees = eligibleAssigneesForScope(
|
||||
item.workgroupId,
|
||||
item.vendorId,
|
||||
"quality_reviewer",
|
||||
strictThreeRole ? "acceptance_reviewer" : "quality_reviewer",
|
||||
item.assignedUserId,
|
||||
);
|
||||
return (
|
||||
<div key={item.id} className={`${panelClass} space-y-4 border-blue-500/30 p-5`}>
|
||||
<div className="flex flex-wrap items-start justify-between gap-3">
|
||||
<div>
|
||||
<div className="text-base font-semibold text-white">包前最终验收 · 全部切片汇总</div>
|
||||
<div className="text-base font-semibold text-white">整包最终验收 · 全部切片汇总</div>
|
||||
<div className="mt-1 text-xs text-gray-400">
|
||||
{statistics.taskCount || evidenceItems.length || 0} 个任务 · {statistics.sliceCount || 0}{" "}
|
||||
个最终切片 · {statistics.annotationSegmentCount || 0} 条语义标注
|
||||
@ -1422,97 +1466,175 @@ export default function AnnotationOperations() {
|
||||
</div>
|
||||
{claimedByMe ? (
|
||||
<div className="space-y-2 rounded-xl border border-emerald-500/30 bg-emerald-500/5 p-4">
|
||||
<div className="text-sm font-medium text-emerald-100">包前验收统计(必填)</div>
|
||||
<div className="grid gap-3 md:grid-cols-4">
|
||||
<label className="space-y-1 text-xs text-gray-300">
|
||||
<span>视频质量</span>
|
||||
<select
|
||||
className={inputClass}
|
||||
value={acceptanceStatistics.videoQuality}
|
||||
onChange={(event) =>
|
||||
setPrepackageAcceptanceDrafts((current) => ({
|
||||
...current,
|
||||
[item.id]: { ...acceptanceStatistics, videoQuality: event.target.value },
|
||||
}))
|
||||
}
|
||||
>
|
||||
<option value="" disabled>
|
||||
请选择
|
||||
</option>
|
||||
<option value="qualified">合格</option>
|
||||
<option value="unqualified">不合格</option>
|
||||
</select>
|
||||
</label>
|
||||
<label className="space-y-1 text-xs text-gray-300">
|
||||
<span>标注准确性(0–100)</span>
|
||||
<input
|
||||
className={inputClass}
|
||||
type="number"
|
||||
min="0"
|
||||
max="100"
|
||||
value={acceptanceStatistics.annotationAccuracy}
|
||||
onChange={(event) =>
|
||||
setPrepackageAcceptanceDrafts((current) => ({
|
||||
...current,
|
||||
[item.id]: { ...acceptanceStatistics, annotationAccuracy: event.target.value },
|
||||
}))
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label className="space-y-1 text-xs text-gray-300">
|
||||
<span>标注完整性(0–100)</span>
|
||||
<input
|
||||
className={inputClass}
|
||||
type="number"
|
||||
min="0"
|
||||
max="100"
|
||||
value={acceptanceStatistics.annotationCompleteness}
|
||||
onChange={(event) =>
|
||||
setPrepackageAcceptanceDrafts((current) => ({
|
||||
...current,
|
||||
[item.id]: { ...acceptanceStatistics, annotationCompleteness: event.target.value },
|
||||
}))
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label className="space-y-1 text-xs text-gray-300">
|
||||
<span>总体等级</span>
|
||||
<select
|
||||
className={inputClass}
|
||||
value={acceptanceStatistics.overallGrade}
|
||||
onChange={(event) =>
|
||||
setPrepackageAcceptanceDrafts((current) => ({
|
||||
...current,
|
||||
[item.id]: { ...acceptanceStatistics, overallGrade: event.target.value },
|
||||
}))
|
||||
}
|
||||
>
|
||||
<option value="" disabled>
|
||||
请选择
|
||||
</option>
|
||||
<option value="A">A</option>
|
||||
<option value="B">B</option>
|
||||
<option value="C">C</option>
|
||||
<option value="D">D</option>
|
||||
</select>
|
||||
</label>
|
||||
<div className="text-sm font-medium text-emerald-100">
|
||||
{strictThreeRole ? "整包交付决定" : "包前验收统计(必填)"}
|
||||
</div>
|
||||
{strictThreeRole ? (
|
||||
<div className="grid gap-3 md:grid-cols-2">
|
||||
<label className="space-y-1 text-xs text-gray-300">
|
||||
<span>HeadPose</span>
|
||||
<select
|
||||
className={inputClass}
|
||||
value={acceptanceStatistics.headpose}
|
||||
onChange={(event) =>
|
||||
setPrepackageAcceptanceDrafts((current) => ({
|
||||
...current,
|
||||
[item.id]: {
|
||||
...acceptanceStatistics,
|
||||
headpose: event.target.value as "include" | "exclude",
|
||||
},
|
||||
}))
|
||||
}
|
||||
>
|
||||
<option value="include">包含</option>
|
||||
<option value="exclude">排除</option>
|
||||
</select>
|
||||
</label>
|
||||
<label className="space-y-1 text-xs text-gray-300">
|
||||
<span>HandPose</span>
|
||||
<select
|
||||
className={inputClass}
|
||||
value={acceptanceStatistics.handpose}
|
||||
onChange={(event) =>
|
||||
setPrepackageAcceptanceDrafts((current) => ({
|
||||
...current,
|
||||
[item.id]: {
|
||||
...acceptanceStatistics,
|
||||
handpose: event.target.value as "include" | "exclude",
|
||||
},
|
||||
}))
|
||||
}
|
||||
>
|
||||
<option value="include">包含</option>
|
||||
<option value="exclude">排除</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
) : (
|
||||
<div className="grid gap-3 md:grid-cols-4">
|
||||
<label className="space-y-1 text-xs text-gray-300">
|
||||
<span>视频质量</span>
|
||||
<select
|
||||
className={inputClass}
|
||||
value={acceptanceStatistics.videoQuality}
|
||||
onChange={(event) =>
|
||||
setPrepackageAcceptanceDrafts((current) => ({
|
||||
...current,
|
||||
[item.id]: { ...acceptanceStatistics, videoQuality: event.target.value },
|
||||
}))
|
||||
}
|
||||
>
|
||||
<option value="" disabled>
|
||||
请选择
|
||||
</option>
|
||||
<option value="qualified">合格</option>
|
||||
<option value="unqualified">不合格</option>
|
||||
</select>
|
||||
</label>
|
||||
<label className="space-y-1 text-xs text-gray-300">
|
||||
<span>标注准确性(0–100)</span>
|
||||
<input
|
||||
className={inputClass}
|
||||
type="number"
|
||||
min="0"
|
||||
max="100"
|
||||
value={acceptanceStatistics.annotationAccuracy}
|
||||
onChange={(event) =>
|
||||
setPrepackageAcceptanceDrafts((current) => ({
|
||||
...current,
|
||||
[item.id]: { ...acceptanceStatistics, annotationAccuracy: event.target.value },
|
||||
}))
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label className="space-y-1 text-xs text-gray-300">
|
||||
<span>标注完整性(0–100)</span>
|
||||
<input
|
||||
className={inputClass}
|
||||
type="number"
|
||||
min="0"
|
||||
max="100"
|
||||
value={acceptanceStatistics.annotationCompleteness}
|
||||
onChange={(event) =>
|
||||
setPrepackageAcceptanceDrafts((current) => ({
|
||||
...current,
|
||||
[item.id]: { ...acceptanceStatistics, annotationCompleteness: event.target.value },
|
||||
}))
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label className="space-y-1 text-xs text-gray-300">
|
||||
<span>总体等级</span>
|
||||
<select
|
||||
className={inputClass}
|
||||
value={acceptanceStatistics.overallGrade}
|
||||
onChange={(event) =>
|
||||
setPrepackageAcceptanceDrafts((current) => ({
|
||||
...current,
|
||||
[item.id]: { ...acceptanceStatistics, overallGrade: event.target.value },
|
||||
}))
|
||||
}
|
||||
>
|
||||
<option value="" disabled>
|
||||
请选择
|
||||
</option>
|
||||
<option value="A">A</option>
|
||||
<option value="B">B</option>
|
||||
<option value="C">C</option>
|
||||
<option value="D">D</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
)}
|
||||
{strictThreeRole &&
|
||||
(acceptanceStatistics.headpose === "exclude" || acceptanceStatistics.handpose === "exclude") ? (
|
||||
<textarea
|
||||
className={inputClass}
|
||||
rows={2}
|
||||
value={acceptanceStatistics.exclusionReason}
|
||||
onChange={(event) =>
|
||||
setPrepackageAcceptanceDrafts((current) => ({
|
||||
...current,
|
||||
[item.id]: { ...acceptanceStatistics, exclusionReason: event.target.value },
|
||||
}))
|
||||
}
|
||||
placeholder="Pose 排除原因(必填)"
|
||||
/>
|
||||
) : null}
|
||||
<textarea
|
||||
className={inputClass}
|
||||
rows={2}
|
||||
value={reviewComment}
|
||||
onChange={(event) => setReviewComment(event.target.value)}
|
||||
placeholder="验收统计备注(可选)"
|
||||
placeholder={strictThreeRole ? "整包问题说明;打回时必填" : "验收统计备注(可选)"}
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
disabled={saving || !prepackageAcceptanceStatisticsAreValid(acceptanceStatistics)}
|
||||
onClick={() => void confirmPrepackageAcceptance(item, acceptanceStatistics)}
|
||||
className="rounded-lg bg-emerald-600 px-4 py-2 text-sm font-medium text-white disabled:opacity-50"
|
||||
>
|
||||
确认验收并进入打包
|
||||
</button>
|
||||
<div className="text-xs text-emerald-200">此阶段只提供确认,不提供拒绝或打回。</div>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<button
|
||||
type="button"
|
||||
disabled={
|
||||
saving ||
|
||||
(strictThreeRole
|
||||
? !strictAcceptanceDraftIsValid(acceptanceStatistics)
|
||||
: !prepackageAcceptanceStatisticsAreValid(acceptanceStatistics))
|
||||
}
|
||||
onClick={() =>
|
||||
void decidePrepackageAcceptance(item, acceptanceStatistics, "approved", strictThreeRole)
|
||||
}
|
||||
className="rounded-lg bg-emerald-600 px-4 py-2 text-sm font-medium text-white disabled:opacity-50"
|
||||
>
|
||||
验收通过并自动打包
|
||||
</button>
|
||||
{strictThreeRole ? (
|
||||
<button
|
||||
type="button"
|
||||
disabled={saving || !reviewComment.trim()}
|
||||
onClick={() => void decidePrepackageAcceptance(item, acceptanceStatistics, "rejected", true)}
|
||||
className="rounded-lg bg-red-700 px-4 py-2 text-sm font-medium text-white disabled:opacity-50"
|
||||
>
|
||||
整包打回审核员
|
||||
</button>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
@ -2599,9 +2721,9 @@ export default function AnnotationOperations() {
|
||||
}))
|
||||
}
|
||||
>
|
||||
<option value="cutter">人工剪切员</option>
|
||||
<option value="annotator">标注员(剪切审核 + 语义标注)</option>
|
||||
<option value="quality_reviewer">审核员(标注审核 + 最终验收)</option>
|
||||
<option value="annotator">标注员(真实切分 + 语义标注)</option>
|
||||
<option value="quality_reviewer">审核员(切分 + 标注审核)</option>
|
||||
<option value="acceptance_reviewer">最终验收员(整包验收)</option>
|
||||
<option value="vendor_manager">供应商管理员</option>
|
||||
</select>
|
||||
<button
|
||||
|
||||
@ -50,6 +50,11 @@ export const humanLoopApi = {
|
||||
annotationAccuracy?: number;
|
||||
annotationCompleteness?: number;
|
||||
overallGrade?: string;
|
||||
poseDelivery?: {
|
||||
headpose: "include" | "exclude";
|
||||
handpose: "include" | "exclude";
|
||||
reasonCodes?: string[];
|
||||
};
|
||||
},
|
||||
) => apiRequest<HumanItem>(`/api/human-items/${encodeURIComponent(id)}/decisions`, { method: "POST" }, payload),
|
||||
listRejects: async (
|
||||
|
||||
@ -427,6 +427,112 @@ def test_v56_package_recognizes_right_camera_artifact_before_target_port_remap()
|
||||
assert package_operator._right_video_artifacts([artifact]) == [artifact]
|
||||
|
||||
|
||||
def test_v58_package_synchronously_cuts_stereo_pts_and_imu_and_excludes_pose(tmp_path, monkeypatch):
|
||||
left = tmp_path / "capture_camera_left_part0001.mp4"
|
||||
right = tmp_path / "capture_camera_right_part0001.mp4"
|
||||
left.write_bytes(b"left-video")
|
||||
right.write_bytes(b"right-video")
|
||||
left_pts = tmp_path / "capture_camera_left_part0001_pts.csv"
|
||||
right_pts = tmp_path / "capture_camera_right_part0001_pts.csv"
|
||||
left_pts.write_text("timestamp_us\n1000000\n1100000\n1200000\n1300000\n", encoding="utf-8")
|
||||
right_pts.write_text("timestamp_us\n1050000\n1150000\n1250000\n1350000\n", encoding="utf-8")
|
||||
imu = tmp_path / "capture_imu.csv"
|
||||
imu.write_text(
|
||||
"timestamp_us\t,x\t,y\t,z\t,type\n"
|
||||
"900000,0,0,9.8,accel\n900000,0,0,0,gyro\n"
|
||||
"1100000,0,0,9.8,accel\n1100000,0,0,0,gyro\n"
|
||||
"1200000,0,0,9.8,accel\n1200000,0,0,0,gyro\n"
|
||||
"1400000,0,0,9.8,accel\n1400000,0,0,0,gyro\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
camera_calibration = tmp_path / "capture_calibration_camera.yaml"
|
||||
imu_calibration = tmp_path / "capture_calibration_imu.yaml"
|
||||
camera_calibration.write_text("camera: real\n", encoding="utf-8")
|
||||
imu_calibration.write_text("imu: real\n", encoding="utf-8")
|
||||
canonical = '{"accepted":true,"pose":"policy"}'
|
||||
acceptance = {
|
||||
"canonical": canonical,
|
||||
"sha256": hashlib.sha256(canonical.encode("utf-8")).hexdigest(),
|
||||
"confirmedByUserId": "acceptance-user",
|
||||
"poseDelivery": {"headpose": "exclude", "handpose": "include", "reasonCodes": ["headpose_unqualified"]},
|
||||
}
|
||||
accepted = {
|
||||
"schemaVersion": "droboticflow.annotation.accepted-partition/v1",
|
||||
"annotationCount": 1,
|
||||
"items": [{
|
||||
"clipId": "capture-final-001",
|
||||
"clipName": "capture-final-001-left.mp4",
|
||||
"clipPath": str(left),
|
||||
"collectionId": "capture",
|
||||
"sourceVideo": left.name,
|
||||
"startSecond": 0.1,
|
||||
"endSecond": 0.3,
|
||||
"sourceStartSecond": 0.1,
|
||||
"sourceEndSecond": 0.3,
|
||||
"finalAcceptanceConfirmed": True,
|
||||
"finalAcceptance": acceptance,
|
||||
"annotation": {"actions": [{"labelId": "06"}]},
|
||||
}],
|
||||
}
|
||||
headpose = {"schemaVersion": "droboticflow.headpose/v1", "enabled": True, "frames": [{"timestampSeconds": 0.2}]}
|
||||
handpose = {"schemaVersion": "droboticflow.wilor.hand_pose_result/v1", "enabled": True, "result": {"frames": [{"timestampMs": 200}]}}
|
||||
inputs = [
|
||||
{"name": "accepted.json", "type": "json", "data": accepted},
|
||||
{"name": right.name, "path": str(right), "type": "video", "portId": "rightVideos", "data": {"collectionId": "capture", "cameraSide": "right"}},
|
||||
{"name": left_pts.name, "path": str(left_pts), "type": "file", "portId": "leftTimestamps", "data": {"collectionId": "capture"}},
|
||||
{"name": right_pts.name, "path": str(right_pts), "type": "file", "portId": "rightTimestamps", "data": {"collectionId": "capture"}},
|
||||
{"name": imu.name, "path": str(imu), "type": "file", "portId": "imu", "data": {"collectionId": "capture"}},
|
||||
{"name": camera_calibration.name, "path": str(camera_calibration), "type": "file", "portId": "calibrations", "data": {"collectionId": "capture"}},
|
||||
{"name": imu_calibration.name, "path": str(imu_calibration), "type": "file", "portId": "calibrations", "data": {"collectionId": "capture"}},
|
||||
{"name": "headpose.json", "type": "json", "data": headpose},
|
||||
{"name": "handpose.json", "type": "json", "data": handpose},
|
||||
]
|
||||
package_helpers = helpers(
|
||||
params={
|
||||
"REQUIRE_HEADPOSE": "true",
|
||||
"REQUIRE_HANDPOSE": "true",
|
||||
"REQUIRE_STEREO_DELIVERY": "true",
|
||||
"REQUIRE_FINAL_ACCEPTANCE": "true",
|
||||
"SYNCHRONIZED_SIDECARS": "true",
|
||||
"ALLOW_POSE_EXCLUSION": "true",
|
||||
},
|
||||
payloads=[accepted, {}, {}, {}, {}, {}, {}, headpose, handpose],
|
||||
)
|
||||
|
||||
def write_json(run_id, node_id, output_dir, name, data, output=None):
|
||||
path = pathlib.Path(output_dir) / name
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text(json.dumps(data, ensure_ascii=False), encoding="utf-8")
|
||||
return {"id": f"{run_id}-{node_id}-{name}", "name": name, "data": data, "path": str(path)}
|
||||
|
||||
package_helpers.update({
|
||||
"write_json_artifact": write_json,
|
||||
"source_path_from_item": lambda item, name, output, archives=None: pathlib.Path(str((item.get("source") or {}).get("path") or item.get("path"))),
|
||||
"source_ref_from_artifact": lambda artifact: {"path": artifact.get("path", "")},
|
||||
})
|
||||
monkeypatch.setattr(package_operator, "_write_frame_segment", lambda source, destination, start, end: pathlib.Path(destination).write_bytes(b"frame-accurate-video"))
|
||||
monkeypatch.setattr(package_operator, "_ffprobe_frame_count", lambda path: 2 if "final-001" in pathlib.Path(path).name else 4)
|
||||
package_operator._run_fanyu_v5("run-v58", "package", tmp_path / "output", {}, inputs, package_helpers)
|
||||
|
||||
package_dir = tmp_path / "output" / "packages" / "capture-final-001_package"
|
||||
synchronized = json.loads((package_dir / "synchronized-slice.json").read_text(encoding="utf-8"))
|
||||
assert synchronized["schemaVersion"] == "droboticflow.synchronized-slice/v1"
|
||||
assert synchronized["left"]["pts"]["rowCount"] == synchronized["left"]["video"]["frameCount"] == 2
|
||||
assert synchronized["right"]["pts"]["rowCount"] == synchronized["right"]["video"]["frameCount"] == 2
|
||||
assert synchronized["imu"]["sampleCount"] == 4
|
||||
assert (package_dir / "capture-final-001_left_pts.csv").is_file()
|
||||
assert (package_dir / "capture-final-001_right_pts.csv").is_file()
|
||||
assert (package_dir / "capture-final-001_imu.csv").is_file()
|
||||
assert not (package_dir / "headpose.json").exists()
|
||||
assert (package_dir / "handpose.json").is_file()
|
||||
manifest = json.loads((tmp_path / "output" / "packages-manifest.json").read_text(encoding="utf-8"))
|
||||
assert manifest["schemaVersion"] == "droboticflow.delivery.manifest/v4"
|
||||
assert manifest["audioIncluded"] is False
|
||||
assert manifest["headposeIncluded"] is False
|
||||
assert manifest["handposeIncluded"] is True
|
||||
assert len(manifest["calibration"]) == 2
|
||||
|
||||
|
||||
@pytest.mark.parametrize("schema", ["droboticflow.headpose/v1", "droboticflow.wilor.hand_pose_result/v1"])
|
||||
def test_v5_pose_free_package_rejects_unexpected_pose_payloads(tmp_path, schema):
|
||||
accepted = {
|
||||
|
||||
@ -21,19 +21,19 @@ test("annotation workbench separates available, mine, and administrator task poo
|
||||
assert.match(source, /humanLoopApi\.assign/);
|
||||
});
|
||||
|
||||
test("user management exposes cutter, annotator, and reviewer responsibilities", async () => {
|
||||
test("annotation membership exposes the confirmed three-role responsibilities", async () => {
|
||||
const [users, operations, roles] = await Promise.all([
|
||||
readFile(usersURL, "utf8"),
|
||||
readFile(operationsURL, "utf8"),
|
||||
readFile(rolesURL, "utf8"),
|
||||
]);
|
||||
for (const source of [users, operations]) {
|
||||
assert.match(source, /value="cutter">人工剪切员/);
|
||||
assert.match(source, /标注员(剪切审核 \+ 语义标注)/);
|
||||
assert.match(source, /审核员(标注审核 \+ 最终验收)/);
|
||||
}
|
||||
assert.match(roles, /value: "cutter"[\s\S]*label: "人工剪切员"/);
|
||||
assert.match(users, /value="cutter"/);
|
||||
assert.match(operations, /标注员(真实切分 \+ 语义标注)/);
|
||||
assert.match(operations, /审核员(切分 \+ 标注审核)/);
|
||||
assert.match(operations, /最终验收员(整包验收)/);
|
||||
assert.match(roles, /value: "cutter"[\s\S]*label: "旧版剪切员(兼容)"/);
|
||||
assert.match(roles, /value: "quality_reviewer"[\s\S]*label: "审核员"/);
|
||||
assert.match(roles, /value: "acceptance_reviewer"[\s\S]*label: "最终验收员"/);
|
||||
});
|
||||
|
||||
test("human-loop client supports audited administrator assignment", async () => {
|
||||
|
||||
@ -32,18 +32,14 @@ test("human roles see only their assigned navigation surfaces", async () => {
|
||||
assert.match(sidebar, /getPluginPrimaryNavigationContributions\(pluginStatuses, role\)/);
|
||||
assert.match(
|
||||
registry,
|
||||
/Label: "语义标注"[\s\S]*GroupLabel: "标注中心"[\s\S]*RequiredRoles: \[\]string\{"admin", "annotator"\}/,
|
||||
/Label: "切分与语义标注"[\s\S]*GroupLabel: "标注中心"[\s\S]*RequiredRoles: \[\]string\{"admin", "annotator"\}/,
|
||||
);
|
||||
assert.match(
|
||||
registry,
|
||||
/Label: "标注审核"[\s\S]*GroupLabel: "标注中心"[\s\S]*RequiredRoles: \[\]string\{"admin", "quality_reviewer"\}/,
|
||||
/Label: "切分与标注审核"[\s\S]*GroupLabel: "标注中心"[\s\S]*RequiredRoles: \[\]string\{"admin", "quality_reviewer"\}/,
|
||||
);
|
||||
assert.match(
|
||||
registry,
|
||||
/Label: "最终验收"[\s\S]*RequiredRoles: \[\]string\{"admin", "quality_reviewer", "acceptance_reviewer"\}/,
|
||||
);
|
||||
assert.match(registry, /ID: "clip"[\s\S]*RequiredRoles: \[\]string\{"admin", "cutter"\}/);
|
||||
assert.match(registry, /ID: "clip-quality"[\s\S]*RequiredRoles: \[\]string\{"admin", "annotator"\}/);
|
||||
assert.match(registry, /Label: "最终验收"[\s\S]*RequiredRoles: \[\]string\{"admin", "acceptance_reviewer"\}/);
|
||||
assert.doesNotMatch(registry, /Navigation:[\s\S]*ID: "clip"[\s\S]*Label: "人工剪切"/);
|
||||
assert.doesNotMatch(sidebar, /path: "\/monitoring",\s+roles: \[.*"supplier_manager".*\]/);
|
||||
});
|
||||
|
||||
@ -54,7 +50,7 @@ test("workflow run input renders a per-run automatic HandPose switch", async ()
|
||||
assert.match(source, /includeHandpose: event\.target\.checked/);
|
||||
});
|
||||
|
||||
test("v5 submits an explicit empty semantic list and requires independent prepackage statistics", async () => {
|
||||
test("v5.8 submits a combined revision and uses strict whole-package acceptance", async () => {
|
||||
const source = await readFile(annotationURL, "utf8");
|
||||
assert.match(source, /if \(!detail\?\.humanItem \|\| sliceSegments\.length === 0\) return/);
|
||||
assert.doesNotMatch(
|
||||
@ -62,10 +58,10 @@ test("v5 submits an explicit empty semantic list and requires independent prepac
|
||||
/if \(!detail\?\.humanItem \|\| sliceSegments\.length === 0 \|\| segments\.length === 0\) return/,
|
||||
);
|
||||
assert.match(source, /segments,\s*changeReason: detail\.task\.currentRevision/);
|
||||
assert.match(source, /包前验收统计(必填)/);
|
||||
assert.match(source, /整包交付决定/);
|
||||
assert.match(source, /prepackageAcceptanceDrafts/);
|
||||
assert.match(source, /videoQuality: statistics\.videoQuality/);
|
||||
assert.match(source, /prepackageAcceptanceStatisticsAreValid/);
|
||||
assert.match(source, /poseDelivery:/);
|
||||
assert.match(source, /整包打回审核员/);
|
||||
});
|
||||
|
||||
test("supplier managers are redirected away from non-dashboard deep links", async () => {
|
||||
|
||||
@ -24,16 +24,16 @@ test("v5 queues each supplier task in exactly its configured human stage", async
|
||||
assert.match(source, /打回人工调切/);
|
||||
});
|
||||
|
||||
test("cutter, annotator, and reviewer receive their required workbench routes", async () => {
|
||||
test("v5.8 annotator reviewer and acceptance roles receive independent workbenches", async () => {
|
||||
const sidebar = await readFile(sidebarURL, "utf8");
|
||||
const app = await readFile(appURL, "utf8");
|
||||
const registry = await readFile(pluginRegistryURL, "utf8");
|
||||
assert.match(sidebar, /getPluginPrimaryNavigationContributions\(pluginStatuses, role\)/);
|
||||
assert.match(registry, /ID: "clip"[\s\S]*Label: "人工剪切"[\s\S]*RequiredRoles: \[\]string\{"admin", "cutter"\}/);
|
||||
assert.match(registry, /ID: "clip-quality"[\s\S]*Label: "剪切审核"/);
|
||||
assert.match(registry, /Label: "切分与语义标注"[\s\S]*RequiredRoles: \[\]string\{"admin", "annotator"\}/);
|
||||
assert.match(registry, /Label: "最终验收"[\s\S]*RequiredRoles: \[\]string\{"admin", "acceptance_reviewer"\}/);
|
||||
assert.match(registry, /GroupID: "annotation-center"[\s\S]*GroupLabel: "标注中心"/);
|
||||
assert.match(app, /effectiveRole === "cutter"[\s\S]*path\.endsWith\("\/clip"\)/);
|
||||
assert.match(app, /path\.endsWith\("\/annotate"\) \|\| path\.endsWith\("\/clip-quality"\)/);
|
||||
assert.match(app, /effectiveRole === "annotator"[\s\S]*path\.endsWith\("\/annotate"\)/);
|
||||
assert.match(app, /effectiveRole === "acceptance_reviewer"[\s\S]*path\.endsWith\("\/acceptance"\)/);
|
||||
});
|
||||
|
||||
test("aggregate confirmation renders HeadPose while HandPose bypasses human review", async () => {
|
||||
@ -44,7 +44,7 @@ test("aggregate confirmation renders HeadPose while HandPose bypasses human revi
|
||||
assert.match(source, /buildBrowserPlayableVideoURL\(evidenceURL\)/);
|
||||
assert.match(source, /自动生成,无需人工质检/);
|
||||
assert.doesNotMatch(source, /title="手部预标(标手辅助)"/);
|
||||
assert.match(source, /确认验收并进入打包/);
|
||||
assert.match(source, /验收通过并自动打包/);
|
||||
assert.doesNotMatch(source, /确认验收并释放训练与打包/);
|
||||
assert.match(source, /item\.itemIds\.length/);
|
||||
assert.match(source, /item\.finalExportArtifactIds\?\.length/);
|
||||
|
||||
@ -74,9 +74,9 @@ test("grouped plugin primary entry stays active on every contributed stage route
|
||||
assert.equal(matchesPluginNavigationPath("/plugins/another-plugin/workflows/workflow-1/quality", "/quality"), false);
|
||||
});
|
||||
|
||||
test("plugin navigation preserves legacy role compatibility", () => {
|
||||
test("plugin navigation keeps acceptance reviewer independent", () => {
|
||||
assert.equal(resolvePluginNavigationRole("data_operator"), "annotator");
|
||||
assert.equal(resolvePluginNavigationRole("qa_reviewer"), "quality_reviewer");
|
||||
assert.equal(resolvePluginNavigationRole("acceptance_reviewer"), "quality_reviewer");
|
||||
assert.equal(resolvePluginNavigationRole("acceptance_reviewer"), "acceptance_reviewer");
|
||||
assert.equal(resolvePluginNavigationRole("pipeline_engineer"), "admin");
|
||||
});
|
||||
|
||||
@ -31,7 +31,7 @@ test("workflow capability access follows the annotation duty role", () => {
|
||||
assert.equal(canAccessWorkflowCapability("annotator", "human_annotation"), true);
|
||||
assert.equal(canAccessWorkflowCapability("quality_reviewer", "human_quality_review"), true);
|
||||
assert.equal(canAccessWorkflowCapability("acceptance_reviewer", "human_acceptance"), true);
|
||||
assert.equal(canAccessWorkflowCapability("quality_reviewer", "human_acceptance"), true);
|
||||
assert.equal(canAccessWorkflowCapability("quality_reviewer", "human_acceptance"), false);
|
||||
assert.equal(canAccessWorkflowCapability("data_operator", "human_annotation"), true);
|
||||
assert.equal(canAccessWorkflowCapability("data_operator", "human_quality_review"), false);
|
||||
assert.equal(canAccessWorkflowCapability("qa_reviewer", "human_quality_review"), true);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user