commit fdf4c912858014036981ad480a7617a39fcad2d0

diff --git a/lab_start.sh b/lab_start.sh
index 883b385..a1969d5 100755
--- a/lab_start.sh
+++ b/lab_start.sh
@@ -40,6 +40,8 @@
 #                      流れ・引数は so101c と同じ (--exec-steps は 1〜30. --rtc・--blend も使える). 正規化の値・安全範囲はこの 50 本から
 #              --blend N (so101a〜so101d. 0〜15. 依頼 308): run_so101_policy.py にそのまま渡す (答えの切り替えを N コマかけて
 #                      前の答えと混ぜる. 爪は混ぜない. 0 か付けなければ今までどおり). 起動時に [SO101] で出す
+#              --max-step-deg X (so101a〜so101d. 1〜10. 依頼 313): run_so101_policy.py にそのまま渡す (関節 5 つの 1 コマの変化の
+#                      上限を X° に下げる. 爪の 20 は変えない. 10 か付けなければ今までどおり). 起動時に [SO101] で出す
 #              取る場所・設定・assets・サーバーの起動・つなぎ直しの確かめが選んだモデルに合う. 安全範囲 (学習データ ±10°.
 #              run_policy_client.py --raw-dir) は, deep1・deep1b は deep_even10_v1 の raw_episodes (依頼 135), ほかは trim2 の
 #              raw_episodes (corr_v3・corr_v4 と合わせても範囲はほぼ同じで, trim2 の方が狭い. corr_v5 は 11-06 の 184650 の j2 が
@@ -125,6 +127,7 @@ PLAY_SPEED=""        # 依頼 288: so101a だけ. 付けなければ run_so101_p
 RTC=0                # 依頼 294: so101b だけ. 1 ならサーバーを rtc_serve.py で起動し, 空打ちとクライアントに --rtc を渡す
 RTC_ARGS=()
 BLEND=""             # 依頼 308: so101a〜so101d (依頼 309). 付けなければ run_so101_policy.py の既定 (0 = 混ぜない)
+MAX_STEP_DEG=""      # 依頼 313: so101a〜so101d. 付けなければ run_so101_policy.py の既定 (10 = 今までどおり)
 MECHARM_ONLY=()      # 依頼 283: so101a では使えない mechArm の引数 (付けられていれば止める)
 for a in "$@"; do
     case "$a" in --episode|--no-tilt-fix|--grip-value|--flow|--via-stride|--step-confirm|--no-auto-finish|--speed) MECHARM_ONLY+=("$a") ;; esac
@@ -165,10 +168,13 @@ while [ $# -gt 0 ]; do
                  case "$2" in ''|*[!0-9]*) echo "[ERROR] --blend は 0〜15 の整数: $2" >&2; exit 2 ;; esac
                  [ ${#2} -le 2 ] && [ "$((10#$2))" -le 15 ] || { echo "[ERROR] --blend は 0〜15 の整数: $2" >&2; exit 2; }
                  BLEND="$((10#$2))"; shift 2 ;;
+        --max-step-deg) [ $# -ge 2 ] || { echo "[ERROR] --max-step-deg には 1〜10 の数を付ける (例 4)" >&2; exit 2; }     # 依頼 313
+                        [[ "$2" =~ ^([1-9](\.[0-9]+)?|10(\.0+)?)$ ]] || { echo "[ERROR] --max-step-deg は 1〜10 の数 (例 4・3.5): $2" >&2; exit 2; }
+                        MAX_STEP_DEG="$2"; shift 2 ;;
         --play-speed) [ $# -ge 2 ] || { echo "[ERROR] --play-speed には 0 より大きく 1 までの数を付ける (例 0.8)" >&2; exit 2; }     # 依頼 288 (so101a だけ)
                       [[ "$2" =~ ^(0\.[0-9]{1,3}|1|1\.0{1,3})$ ]] && [[ ! "$2" =~ ^0\.0+$ ]] || { echo "[ERROR] --play-speed は 0 より大きく 1 までの数 (例 0.8): $2" >&2; exit 2; }
                       PLAY_SPEED="$2"; shift 2 ;;
-        -h|--help) sed -n '2,86p' "$0"; exit 0 ;;
+        -h|--help) sed -n '2,88p' "$0"; exit 0 ;;
         *) echo "[ERROR] 知らない引数: $1  (./lab_start.sh --help)" >&2; exit 2 ;;
     esac
 done
@@ -199,6 +205,9 @@ fi
 if [ $SO101 = 0 ] && [ -n "$BLEND" ]; then         # 依頼 308
     echo "[ERROR] --blend は --model so101a〜so101d だけ" >&2; exit 2
 fi
+if [ $SO101 = 0 ] && [ -n "$MAX_STEP_DEG" ]; then  # 依頼 313
+    echo "[ERROR] --max-step-deg は --model so101a〜so101d だけ" >&2; exit 2
+fi
 if [ $RTC = 1 ] && [ "$MODEL" != so101b ] && [ "$MODEL" != so101c ] && [ "$MODEL" != so101d ]; then      # 依頼 307: so101c も. 依頼 309: so101d も
     echo "[ERROR] --rtc は --model so101b・so101c・so101d だけ" >&2; exit 2
 fi
@@ -256,6 +265,7 @@ if [ $SO101 = 1 ]; then     # 依頼 283: mechArm の位置合わせ・傾き・
     else echo "[SO101 ] 次の問い合わせ: 答えを実行している間に先に出す (既定. 依頼 285)"; fi
     [ -z "$PLAY_SPEED" ] || echo "[SO101 ] 答えを流す速さ: $PLAY_SPEED (--play-speed. 1 コマの間 1/(30×$PLAY_SPEED) 秒. 依頼 288)"
     [ -z "$BLEND" ] || echo "[SO101 ] 答えの切り替え: $BLEND コマかけて前の答えと混ぜる (--blend $BLEND. 0 は混ぜない. 爪は混ぜない. 依頼 308)"
+    [ -z "$MAX_STEP_DEG" ] || echo "[SO101 ] 1 コマの変化の上限: 関節 5 つ ${MAX_STEP_DEG}° (--max-step-deg ${MAX_STEP_DEG}. 爪は 20 のまま. 10 は今までどおり. 依頼 313)"
     [ $RTC = 0 ] || echo "[SO101 ] 答えのつなぎ方: RTC (--rtc. サーバーは rtc_serve.py. 前の答えの残りと待ちのコマ数 d を付けて先に問い合わせる. 依頼 294)"
 else
 echo "[FRAME ] 写り方の確かめの基準画像は $RAW の最初のエピソードから (位置合わせと同じ trim2. 依頼 137)"
@@ -667,6 +677,7 @@ while :; do
         [ -n "$PLAY_SPEED" ] && SO101_ARGS+=(--play-speed "$PLAY_SPEED")
         [ $RTC = 1 ] && SO101_ARGS+=(--rtc)         # 依頼 294
         [ -n "$BLEND" ] && SO101_ARGS+=(--blend "$BLEND")     # 依頼 308
+        [ -n "$MAX_STEP_DEG" ] && SO101_ARGS+=(--max-step-deg "$MAX_STEP_DEG")     # 依頼 313
         [ $DRY_RUN = 0 ] && SO101_ARGS+=(--execute)
         "$LAB_SO101_PY" so101/run_so101_policy.py "${SO101_ARGS[@]}" ${CONFIRM_ARGS[@]+"${CONFIRM_ARGS[@]}"}
         rc=$?
diff --git a/logs/20261127_0800.md b/logs/20261127_0800.md
new file mode 100644
index 0000000..686fd62
--- /dev/null
+++ b/logs/20261127_0800.md
@@ -0,0 +1,9 @@
+# 依頼 313 SO-101 の 1 コマの上限を --max-step-deg で下げられるようにする (2026-11-27. フォロワーは動かしていない・Pod には触っていない)
+
+- run_so101_policy.py --max-step-deg X (1〜10. 既定 10 = 今までどおり). 関節 5 つだけ. 爪 20 は変えない. B と同じ所 (混ぜたあと・安全範囲のあと) で前に送った値から ±X
+- 記録: trial.json・台帳の max_step_deg (台帳は最後の列)・trial.json の step_clipped_frames・LeRobot の ptm.max_step_deg (X < 10 のときだけ). 表示 [STEP]
+- lab_start.sh --max-step-deg X を so101a〜d のクライアントへ渡す
+- 勧める値 5 (so101_Log12 の 073444〜074041 の 6 本の ptm.sent: つかむ所 99% 4.75°・5° で切るのは 0.7%・ずれ最大 0.6°. 運ぶ所 99% 7.7〜8.2°・最大 9.8°). 表と理由は so101/check_313/REPORT_313.md
+- すぐ打つ行: ./lab_start.sh --model so101b --log so101_Log12 --blend 10 --max-step-deg 5
+- テスト: test_run_so101_policy 89・test_lab_start 386・test_lab_train 297・test_lerobot_safe_259 64・test_so101_train 15・test_so101_rtc 9 件 OK
+- codex: ❌ 小数 3 桁を受けない → 直した. ⚠️ 台帳の見出し → 決まりどおり据え置き
diff --git a/so101/check_313/REPORT_313.md b/so101/check_313/REPORT_313.md
new file mode 100644
index 0000000..c0cc550
--- /dev/null
+++ b/so101/check_313/REPORT_313.md
@@ -0,0 +1,65 @@
+# 依頼 313: SO-101 の 1 コマで動ける角度の上限を引数で下げられるようにする
+
+## エイイチがすぐ打つ行
+
+```
+./lab_start.sh --model so101b --log so101_Log12 --blend 10 --max-step-deg 5
+```
+
+（同じ Pod のままつなぎ直す。--gpu などはいつもの値。Pod は消していない・止めていない）
+
+## やったこと
+
+- `so101/run_so101_policy.py` に `--max-step-deg X`（1〜10。付けなければ 10 = 今までどおり）
+  - 送る直前（入口の B と同じ所。blend で混ぜたあと・安全範囲で切ったあと）に、関節 5 つを前に送った値から ±X° に切る（`step_clip`）。爪は切らない（20 は入口の B のまま）
+  - 推論・手直し・一時停止のどれで送るときも効く（B と同じ）
+  - 10 を超える値・1 未満・nan・inf は受けない。10 のときは何も切らない
+  - 記録: trial.json と台帳 so101_trials.csv に `max_step_deg`（台帳は最後の列に足す。見出しは書き換えない＝依頼 288 からの決まり）。trial.json に `step_clipped_frames`（X で切ったコマ数）。LeRobot には X が 10 より小さいときだけ `ptm.max_step_deg` の列を作る
+  - 表示: [FIRST] の「1 コマ 関節 X°」、[MODE] に上限の行、終わりに [STEP] で切ったコマ数。[JUMP] はこれまでどおり（送った値で数える）
+- `lab_start.sh` に `--max-step-deg X`（so101a〜so101d だけ）。クライアントへそのまま渡す。空打ちには渡さない。[SO101] で出す
+- テスト: 付けないとき・10 のとき、送る値・記録・問い合わせが依頼 313 の前の版 (c123ea8) と同じ（blend あり・RTC・exec-steps も）。上限が効く・混ぜたあとに当たる・手直し・一時停止でも効く・爪は切らない・引数の検査
+
+## 分布（so101_Log12 の so101_20261127_073444〜074041 の 6 本・ptm.sent の 1 コマの変化 |Δ|・度）
+
+値は 50% / 90% / 99%（最大）。区間は爪の送った値で分けた（成功 4 本）。
+
+| 区間 (コマ) | shoulder_pan | shoulder_lift | elbow_flex | wrist_flex | wrist_roll | 5 関節の最大 |
+|---|---|---|---|---|---|---|
+| 6 本全部 (4031) | 0.20/2.42/6.77 (9.9) | 0.27/2.61/6.88 (10.0) | 0.27/2.58/6.73 (9.8) | 0.28/1.66/3.78 (5.5) | 0.11/0.87/2.24 (4.3) | 0.72/3.71/8.13 (10.0) |
+| 寄る (510) | 0.23/1.09/1.92 (2.3) | 0.45/3.73/7.08 (8.2) | 0.62/2.68/3.99 (5.1) | 0.41/1.63/3.09 (3.6) | 0.21/0.73/2.11 (2.3) | 1.00/3.74/7.08 (8.2) |
+| つかむ (296) | 0.10/0.94/2.26 (2.4) | 0.17/1.21/4.75 (5.4) | 0.24/1.25/1.97 (2.1) | 0.28/1.32/3.83 (4.3) | 0.11/1.35/2.10 (2.2) | 0.58/2.09/4.75 (5.4) |
+| 運ぶ (379) | 0.44/3.23/7.71 (9.1) | 0.58/2.54/8.16 (9.8) | 0.46/3.22/8.15 (9.8) | 0.44/2.11/4.91 (5.5) | 0.23/1.21/3.38 (4.3) | 1.33/4.50/9.35 (9.8) |
+| 放して戻る (330) | 0.30/2.09/4.56 (5.2) | 0.81/4.38/7.12 (7.8) | 0.64/4.16/5.88 (6.2) | 0.79/2.44/3.48 (4.4) | 0.09/0.53/1.28 (1.5) | 1.15/4.53/7.12 (7.8) |
+| 戻ったあと (844) | 0.06/0.18/0.42 (0.6) | 0.07/0.23/0.52 (0.9) | 0.06/0.23/0.62 (1.0) | 0.05/0.30/0.94 (1.3) | 0.03/0.15/0.66 (0.9) | 0.16/0.39/0.97 (1.3) |
+
+区間: 寄る＝始め〜爪を閉じる 2 秒前 / つかむ＝閉じる 2 秒前〜閉じて 0.5 秒 / 運ぶ＝箱で開くまで / 放して戻る＝箱で開いてから爪を閉じるまで（振り戻しはここ）/ 戻ったあと＝閉じたあと。
+
+上限 N で切ったとき（送った道をそのまま切った見積もり。実機では次の答えが今の位置から出るので遅れはこれより小さくなるはず）:
+
+| N | 寄る 切る割合・遅れ最大 | つかむ | 運ぶ | 放して戻る |
+|---|---|---|---|---|
+| 3 | 17.6%・30.3° | 4.7%・10.7° | 20.3%・38.7° | 26.1%・24.5° |
+| 4 | 7.8%・19.0° | 2.0%・4.7° | 12.4%・29.9° | 15.8%・17.0° |
+| **5** | 2.9%・12.2° | **0.7%・0.6°** | 8.7%・22.8° | 8.2%・10.1° |
+| 6 | 1.8%・7.2° | 0.0%・0.0° | 6.9%・15.8° | 3.6%・5.0° |
+
+## 選んだ値: 5°
+
+つかむ所は 99% が 4.75° で、5° なら切るのは 0.7%・ずれは最大 0.6° とほとんど変わらない。運ぶ所・放して戻る所の 99%（7〜8°）と最大（9.8°）を 5°（150°/秒）で抑え、そこのコマの 8〜9% を切る。4° ではつかむ所のずれが最大 4.7° まで増える。
+
+## テスト
+
+- test_run_so101_policy 89 件 OK（前 79 + 依頼 313 で 10）
+- test_lab_start 386 件 OK（前 364 + 依頼 313 で 22）
+- test_lab_train 297・test_lerobot_safe_259 64・test_so101_train 15（3 件は飛ばし）・test_so101_rtc 9 件 OK
+
+## codex（codex exec -s read-only・差分だけ）
+
+- ❌ lab_start.sh が小数 3 桁以上（例 4.125）を受けない → 直した（小数の桁数を決めない。テストを足した）
+- ⚠️ 台帳の見出しを書き換えずに列を足すので、ふつうの csv.DictReader では max_step_deg を名前で読めない → 依頼 288 からの決まり（KIOXIA の台帳の見出しを書き換えない。読むときは TRIAL_COLUMNS を名前に使う）どおりなので据え置き
+- 自分で見つけて直した: lab_start.sh の `$MAX_STEP_DEG°` で `°` が変数名に混ざり（unbound variable）止まっていた → `${MAX_STEP_DEG}°` に直した（テストで見つかった）
+- ✅ 推論・手直し・一時停止に効き、10 超は指定できない。爪は切らない。既定 10 は送る経路を変えず LeRobot の列も増えない
+
+## 気をつけること
+
+- 寄る所（ブロックへ下りる shoulder_lift）も 2.9% 切られ、送った道のままなら最大 12° 遅れる。場所 4 は前から届いていないので、5° で場所 4 が悪くなるかは実機で見る
diff --git a/so101/check_313/dist_313.py b/so101/check_313/dist_313.py
new file mode 100644
index 0000000..89957a3
--- /dev/null
+++ b/so101/check_313/dist_313.py
@@ -0,0 +1,72 @@
+"""依頼 313: 11-27 朝の so101b + --blend 10 の 6 本で, 送った目標 (ptm.sent) の 1 コマの変化の分布を関節ごと・区間ごとに出す.
+区間は爪の送った値で分ける (成功 4 本): reach=始め〜閉じる 2 秒前 / grasp=閉じる 2 秒前〜閉じて 0.5 秒 / carry=箱で開くまで /
+release=箱で開いてから閉じるまで (放して戻る振り) / return=閉じたあと. all6 は 6 本全部. 最後に上限 N で切ったときの
+(推論を閉じずに送った道をそのまま切る) 切るコマの割合と遅れ. 読むだけ (KIOXIA に書かない)."""
+import glob, json, numpy as np, pandas as pd
+J = ["shoulder_pan", "shoulder_lift", "elbow_flex", "wrist_flex", "wrist_roll"]
+TR = ["073444","073553","073656","073800","073931","074041"]
+base = "/Volumes/KIOXIA/r2r2r-data/lab/so101_Log12/so101/so101_20261127_"
+def intervals(mask):
+    out, i = [], 0
+    while i < len(mask):
+        if mask[i]:
+            j = i
+            while j < len(mask) and mask[j]: j += 1
+            if j - i >= 5: out.append((i, j))
+            i = j
+        else: i += 1
+    return out
+phase_d = {k: [] for k in ("all6", "reach", "grasp", "carry", "release", "return")}
+paths = {k: [] for k in ("reach", "grasp", "carry", "release", "return", "all6")}
+for t in TR:
+    tj = json.load(open(base + t + "/trial.json"))
+    df = pd.read_parquet(glob.glob(base + t + "/data/*/*.parquet")[0])
+    s = np.stack(df["ptm.sent"].values).astype(np.float64)
+    mode = np.array([int(np.asarray(m).reshape(-1)[0]) for m in df["ptm.mode"].values])
+    assert (mode == 0).all()
+    d = np.abs(np.diff(s[:, :5], axis=0))          # d[i] = frame i -> i+1
+    phase_d["all6"].append(d); paths["all6"].append(s[:, :5])
+    if tj["result"] != "success":
+        continue
+    g = s[:, 5]
+    def first(cond, start, hold):
+        for i in range(start, len(g) - hold):
+            if all(cond(g[i + k]) for k in range(hold)):
+                return i
+        raise ValueError(t)
+    o1 = first(lambda v: v > 15, 0, 10)          # 開き始め (ブロックへ)
+    c1 = first(lambda v: v < 15, o1, 20)         # つかんで閉じた
+    o2 = first(lambda v: v > 15, c1, 10)         # 箱で放す
+    c2 = first(lambda v: v < 15, o2, 20)         # 放して閉じた → 戻る
+    seg = {"reach": (0, c1 - 60), "grasp": (c1 - 60, c1 + 15), "carry": (c1 + 15, o2), "release": (o2, c2), "return": (c2, len(s))}
+    print(t, tj["place"], {k: (v[0], v[1], v[1]-v[0]) for k, v in seg.items()})
+    for k, (x, y) in seg.items():
+        phase_d[k].append(d[x:max(x, y - 1)])
+        if k in paths: paths[k].append(s[x:y, :5])
+def row(name, d):
+    d = np.concatenate(d)
+    cells = []
+    for j in range(5):
+        p = np.percentile(d[:, j], [50, 90, 99])
+        cells.append(f"{p[0]:.2f}/{p[1]:.2f}/{p[2]:.2f} (max {d[:, j].max():.1f})")
+    mx = d.max(axis=1)
+    p = np.percentile(mx, [50, 90, 99])
+    print(f"| {name} ({len(d)}) | " + " | ".join(cells) + f" | {p[0]:.2f}/{p[1]:.2f}/{p[2]:.2f} (max {mx.max():.1f}) |")
+print("| 区間 (コマ) | " + " | ".join(J) + " | 5 関節の最大 |")
+for k in phase_d: row(k, phase_d[k])
+def sim(x, n):
+    y = np.empty_like(x); y[0] = x[0]
+    for i in range(1, len(x)):
+        y[i] = np.clip(x[i], y[i-1] - n, y[i-1] + n)
+    return y
+print()
+print("| N | 区間 | 切るコマの割合 | 遅れ (切ったあとと元の差) 最大 ° | 遅れ 99% ° |")
+for n in (3, 4, 5, 6):
+    for k in ("reach", "grasp", "carry", "release", "all6"):
+        frac, lag = [], []
+        for x in paths[k]:
+            y = sim(x, n)
+            dd = np.abs(np.diff(x, axis=0)).max(axis=1)
+            frac.append(dd > n); lag.append(np.abs(y - x).max(axis=1))
+        frac = np.concatenate(frac); lag = np.concatenate(lag)
+        print(f"| {n} | {k} | {frac.mean()*100:.1f}% ({frac.sum()}) | {lag.max():.1f} | {np.percentile(lag, 99):.2f} |")
diff --git a/so101/check_313/dist_313.txt b/so101/check_313/dist_313.txt
new file mode 100644
index 0000000..b3ebca7
--- /dev/null
+++ b/so101/check_313/dist_313.txt
@@ -0,0 +1,33 @@
+073444 1 {'reach': (0, 153, 153), 'grasp': (153, 228, 75), 'carry': (228, 316, 88), 'release': (316, 408, 92), 'return': (408, 647, 239)}
+073553 2 {'reach': (0, 90, 90), 'grasp': (90, 165, 75), 'carry': (165, 274, 109), 'release': (274, 380, 106), 'return': (380, 626, 246)}
+073656 3 {'reach': (0, 150, 150), 'grasp': (150, 225, 75), 'carry': (225, 326, 101), 'release': (326, 390, 64), 'return': (390, 679, 289)}
+074041 5 {'reach': (0, 121, 121), 'grasp': (121, 196, 75), 'carry': (196, 281, 85), 'release': (281, 353, 72), 'return': (353, 427, 74)}
+| 区間 (コマ) | shoulder_pan | shoulder_lift | elbow_flex | wrist_flex | wrist_roll | 5 関節の最大 |
+| all6 (4031) | 0.20/2.42/6.77 (max 9.9) | 0.27/2.61/6.88 (max 10.0) | 0.27/2.58/6.73 (max 9.8) | 0.28/1.66/3.78 (max 5.5) | 0.11/0.87/2.24 (max 4.3) | 0.72/3.71/8.13 (max 10.0) |
+| reach (510) | 0.23/1.09/1.92 (max 2.3) | 0.45/3.73/7.08 (max 8.2) | 0.62/2.68/3.99 (max 5.1) | 0.41/1.63/3.09 (max 3.6) | 0.21/0.73/2.11 (max 2.3) | 1.00/3.74/7.08 (max 8.2) |
+| grasp (296) | 0.10/0.94/2.26 (max 2.4) | 0.17/1.21/4.75 (max 5.4) | 0.24/1.25/1.97 (max 2.1) | 0.28/1.32/3.83 (max 4.3) | 0.11/1.35/2.10 (max 2.2) | 0.58/2.09/4.75 (max 5.4) |
+| carry (379) | 0.44/3.23/7.71 (max 9.1) | 0.58/2.54/8.16 (max 9.8) | 0.46/3.22/8.15 (max 9.8) | 0.44/2.11/4.91 (max 5.5) | 0.23/1.21/3.38 (max 4.3) | 1.33/4.50/9.35 (max 9.8) |
+| release (330) | 0.30/2.09/4.56 (max 5.2) | 0.81/4.38/7.12 (max 7.8) | 0.64/4.16/5.88 (max 6.2) | 0.79/2.44/3.48 (max 4.4) | 0.09/0.53/1.28 (max 1.5) | 1.15/4.53/7.12 (max 7.8) |
+| return (844) | 0.06/0.18/0.42 (max 0.6) | 0.07/0.23/0.52 (max 0.9) | 0.06/0.23/0.62 (max 1.0) | 0.05/0.30/0.94 (max 1.3) | 0.03/0.15/0.66 (max 0.9) | 0.16/0.39/0.97 (max 1.3) |
+
+| N | 区間 | 切るコマの割合 | 遅れ (切ったあとと元の差) 最大 ° | 遅れ 99% ° |
+| 3 | reach | 17.6% (90) | 30.3 | 27.20 |
+| 3 | grasp | 4.7% (14) | 10.7 | 8.51 |
+| 3 | carry | 20.3% (77) | 38.7 | 34.99 |
+| 3 | release | 26.1% (86) | 24.5 | 23.13 |
+| 3 | all6 | 15.0% (604) | 46.3 | 30.59 |
+| 4 | reach | 7.8% (40) | 19.0 | 15.50 |
+| 4 | grasp | 2.0% (6) | 4.7 | 3.09 |
+| 4 | carry | 12.4% (47) | 29.9 | 27.21 |
+| 4 | release | 15.8% (52) | 17.0 | 15.04 |
+| 4 | all6 | 8.5% (343) | 37.7 | 23.90 |
+| 5 | reach | 2.9% (15) | 12.2 | 9.04 |
+| 5 | grasp | 0.7% (2) | 0.6 | 0.18 |
+| 5 | carry | 8.7% (33) | 22.8 | 20.39 |
+| 5 | release | 8.2% (27) | 10.1 | 8.43 |
+| 5 | all6 | 4.9% (199) | 29.7 | 16.27 |
+| 6 | reach | 1.8% (9) | 7.2 | 3.81 |
+| 6 | grasp | 0.0% (0) | 0.0 | 0.00 |
+| 6 | carry | 6.9% (26) | 15.8 | 13.91 |
+| 6 | release | 3.6% (12) | 5.0 | 3.44 |
+| 6 | all6 | 3.2% (128) | 21.8 | 10.06 |
diff --git a/so101/run_so101_policy.py b/so101/run_so101_policy.py
index 6d54299..6917745 100644
--- a/so101/run_so101_policy.py
+++ b/so101/run_so101_policy.py
@@ -30,6 +30,10 @@ mechArm の pi05/run_policy_client.py は使わない (カメラ 2 台・関節
         安全範囲と入口の B (1 コマ 関節 10°・爪 20) は混ぜたあとの値に当てる (緩めない). 始め・一時停止から戻ったときは
         前の答えがないので混ぜない. 混ぜている途中で次の答えに切り替わったら, その答えを前の答えとして
         混ぜ直す (前の答えの値は混ぜる前のもの). --rtc と一緒なら, 前の答えの残りとして送るのは混ぜたあとの値
+    --max-step-deg X (1〜10. 既定 10 = 今までどおり): 関節 5 つの 1 コマの変化の上限を X° にする (依頼 313. 爪の 20 は変えない).
+        入口の B (関節 10°) と同じ所で当てる: 混ぜたあと・安全範囲で切ったあとの目標を, 前に送った値 (arm.last_sent) から
+        ±X° に切って送る (step_clip). 記録の action はこれまでどおり B の前の目標, ptm.sent は切ったあとの値.
+        10 を超える値は受けない (緩める向きには使えない). 10 のときは切らずに今までどおり送る
 
 1 回の流れ:
   1. ブロックの場所の番号 (1〜5) を聞く
@@ -116,12 +120,12 @@ TRIAL_COLUMNS = ["trial", "started_at", "operator", "place", "model", "step", "e
                  "latency_max_s", "clipped_frames", "record_dir", "prefetch", "payload_bytes", "stall_median_s",
                  "stall_max_s", "stall_total_s", "fail_reason", "currents", "play_speed", "rtc", "rtc_d_median",
                  "rtc_s_median", "jump_median_deg", "jump_max_deg", "jump_over3", "jump_target_median_deg",
-                 "jump_target_max_deg", "jump_target_over3", "rtc_s_over", "blend"]
+                 "jump_target_max_deg", "jump_target_over3", "rtc_s_over", "blend", "max_step_deg"]
 # play_speed (依頼 288) より前に作られた so101_trials.csv は見出しに play_speed がない. 見出しは書き換えず (KIOXIA の
 # 既存のファイルを上書きしない), 行の最後に値が 1 つ増えた形で足す (見出しの列の並びは変わらないので前の列は同じ所に入る)
 # rtc〜rtc_s_over (依頼 294) も同じ: 前からある見出しは書き換えず, 行の最後に足す. 見出しの短いファイルを読むときは
 # TRIAL_COLUMNS を名前に使う (例: csv.DictReader(f, fieldnames=TRIAL_COLUMNS) で 1 行目 (見出し) を飛ばす. codex R1 B3)
-# blend (依頼 308) も同じ
+# blend (依頼 308)・max_step_deg (依頼 313) も同じ
 MODEL, CORRECT, PAUSE = 0, 1, 2
 MODE_NAMES = {MODEL: "model", CORRECT: "correct", PAUSE: "pause"}
 CAMERAS = ("desk", "wrist")
@@ -130,6 +134,7 @@ WARMUP_NO_RTC = 3                       # --warmup --rtc で, サーバーが RT
 RTC_DELAY_FRAC = 0.9                    # --rtc の d: 答えが返るまでの時間のこの割合をコマに直して切り上げ (依頼 294)
 JUMP_OVER = 3.0                         # 切り替えの跳びを数える境 (関節 5 つの 1 コマの目標の変化の最大. 度. 依頼 294)
 MAX_BLEND = 15                          # --blend の上限 (依頼 308)
+MAX_STEP_DEG = 10.0                     # --max-step-deg の上限・既定 (入口の B の関節の上限と同じ. 依頼 313. これより緩めない)
 BLEND_GRIP = False                      # --blend で爪も混ぜるか (依頼 308: つかむ・離す所の遅れを見て混ぜないと決めた)
 FAIL_REASONS = {"1": "ブロックまで行かない", "2": "つかめない", "3": "持ち上げで落とす", "4": "箱まで運べない",
                 "5": "箱の外に落とす", "6": "その他"}
@@ -305,6 +310,15 @@ def switch_jumps(targets, chunk_ids, modes=None, joints=5):
     return out
 
 
+def step_clip(target, last_sent, max_step):
+    """--max-step-deg (依頼 313): 関節 5 つを last_sent から ±max_step に切る (爪はそのまま. 爪の上限 20 は入口の B).
+    (切ったあとの目標, 切ったか) を返す"""
+    t = np.asarray(target, dtype=np.float64).copy()
+    last = np.asarray(last_sent, dtype=np.float64)
+    t[:5] = np.clip(t[:5], last[:5] - max_step, last[:5] + max_step)
+    return t, bool(np.any(np.abs(t[:5] - np.asarray(target, dtype=np.float64)[:5]) > 1e-9))
+
+
 def jump_stats(jumps, over=JUMP_OVER):
     """切り替えの跳びの中央値・最大・over 度を超えた回数 (回がなければ None)"""
     if not jumps:
@@ -353,7 +367,7 @@ def stall_of(gaps, fps=FPS):
 
 # ---- 記録 (LeRobot v3.0) ------------------------------------------------------------------------
 
-def dataset_features(current_motors=(), blend=False):
+def dataset_features(current_motors=(), blend=False, max_step=False):
     f = {
         "observation.state": {"dtype": "float32", "shape": (6,), "names": JOINTS},
         "action": {"dtype": "float32", "shape": (6,), "names": JOINTS},
@@ -367,6 +381,8 @@ def dataset_features(current_motors=(), blend=False):
         f["ptm.current"] = {"dtype": "float32", "shape": (len(current_motors),), "names": list(current_motors)}
     if blend:                       # --blend (依頼 308). 0 のときは列を作らない (今までどおり)
         f["ptm.blend_w"] = {"dtype": "float32", "shape": (1,), "names": None}
+    if max_step:                    # --max-step-deg が 10 より小さいとき (依頼 313). 10 のときは列を作らない (今までどおり)
+        f["ptm.max_step_deg"] = {"dtype": "float32", "shape": (1,), "names": None}
     for c in CAMERAS:
         f[f"observation.images.{c}"] = {"dtype": "video", "shape": (CAM_H, CAM_W, 3),
                                          "names": ["height", "width", "channels"]}
@@ -376,12 +392,14 @@ def dataset_features(current_motors=(), blend=False):
 class Recorder:
     """1 回の試行を LeRobot v3.0 の 1 本として書く (お手本と同じ列 + ptm.*)."""
 
-    def __init__(self, root, repo_id, use_videos=True, current_motors=(), blend=False):
+    def __init__(self, root, repo_id, use_videos=True, current_motors=(), blend=False, max_step=None):
         from lerobot.datasets.lerobot_dataset import LeRobotDataset
         self.root = Path(root)
         self.current_motors = list(current_motors)
         self.blend = bool(blend)
-        self.ds = LeRobotDataset.create(repo_id=repo_id, fps=FPS, features=dataset_features(self.current_motors, self.blend),
+        self.max_step = max_step if max_step is not None and max_step < MAX_STEP_DEG else None     # 依頼 313
+        self.ds = LeRobotDataset.create(repo_id=repo_id, fps=FPS,
+                                        features=dataset_features(self.current_motors, self.blend, self.max_step is not None),
                                         root=self.root,
                                         robot_type="so_follower", use_videos=use_videos)
         self.modes, self.n = [], 0
@@ -404,6 +422,8 @@ class Recorder:
             frame["ptm.current"] = np.asarray(c, dtype=np.float32)
         if self.blend:
             frame["ptm.blend_w"] = np.array([blend_w], dtype=np.float32)
+        if self.max_step is not None:
+            frame["ptm.max_step_deg"] = np.array([self.max_step], dtype=np.float32)
         self.ds.add_frame(frame)
         self.modes.append(mode)
         self.n += 1
@@ -657,7 +677,8 @@ def add_rtc(obs, prev, delay):
 
 
 def run_trial(arm, policy, recorder, lo, hi, exec_steps, keys, inp=input, clock=time.perf_counter, sleep=time.sleep,
-              out=print, prefetch=True, skip_confirm=False, play_speed=1.0, rtc=False, rtc_max_delay=None, blend=0):
+              out=print, prefetch=True, skip_confirm=False, play_speed=1.0, rtc=False, rtc_max_delay=None, blend=0,
+              max_step=MAX_STEP_DEG):
     """試行 1 回. 終わったときの情報を返す (記録の close・結果を聞くのは呼ぶ側).
     prefetch: 今の答えの残りが r コマ (prefetch_lead) になったら, そのコマの観測で次を裏で問い合わせておく (依頼 285).
     skip_confirm: 始めの確かめ (Enter) を待たない (2 回目の試行から. 依頼 285)
@@ -666,12 +687,25 @@ def run_trial(arm, policy, recorder, lo, hi, exec_steps, keys, inp=input, clock=
     rtc: 先に問い合わせるとき前の答えの残りと d を付ける (依頼 294. prefetch のときだけ). 次の問い合わせは今の答えの
          d 番目 (以降) のコマで出し, 新しい答えは d コマたって返っていれば次のコマから, 遅れたら返ったコマから使う
     rtc_max_delay: d の上限 (依頼 295. None なら答えのコマ数の半分)
-    blend: 答えを切り替えたら先頭 blend コマを前の答えの同じ時刻のコマと混ぜる (依頼 308. 0 なら今までどおり)"""
+    blend: 答えを切り替えたら先頭 blend コマを前の答えの同じ時刻のコマと混ぜる (依頼 308. 0 なら今までどおり)
+    max_step: 関節 5 つの 1 コマの変化の上限 (度. 依頼 313). 送る直前に前に送った値から ±max_step に切る
+              (入口の B と同じ所. 爪は切らない). MAX_STEP_DEG (10) なら切らない (今までどおり)"""
     if rtc and not prefetch:
         raise ValueError("--rtc は先に問い合わせる形でだけ使える (--no-prefetch とは一緒に使えない)")
+    if not 0 < max_step <= MAX_STEP_DEG:
+        raise ValueError(f"max_step は 0 より大きく {MAX_STEP_DEG:g} まで: {max_step}")
+    limit = max_step < MAX_STEP_DEG
+
+    def send(target):                # 依頼 313: B の前に関節 5 つを ±max_step に切る (10 なら今までどおり B だけ)
+        if limit:
+            target, cut = step_clip(target, arm.last_sent, max_step)
+            info["step_clipped_frames"] += int(cut)
+        return arm.send(target)
+
     play_fps = FPS * play_speed
     info = {"queries": 0, "clipped_frames": 0, "frames": 0, "gaps": [], "waits": [], "skips": [],
-            "jumps": [], "jumps_target": [], "rtc_d": [], "rtc_s": [], "rtc_s_over": 0, "blend": blend, "blend_frames": 0}
+            "jumps": [], "jumps_target": [], "rtc_d": [], "rtc_s": [], "rtc_s_over": 0, "blend": blend, "blend_frames": 0,
+            "max_step_deg": max_step, "step_clipped_frames": 0}
     state, desk, wrist = arm.observe()
     a = ask_model(policy, state, desk, wrist)
     info["queries"] += 1
@@ -682,7 +716,7 @@ def run_trial(arm, policy, recorder, lo, hi, exec_steps, keys, inp=input, clock=
     out(f"[FIRST ] 答えのコマ数   {len(a)} (サーバーの答えから). 1 回で実行するコマ {exec_steps}")
     plan = plan_chunk(a, exec_steps, lo, hi)
     out(f"[FIRST ] 今の角度       {fmt(state)}")
-    out(f"[FIRST ] 最初の目標     {fmt(plan[0][1])}  (1 コマ 関節 10°・爪 20 までで寄せる)")
+    out(f"[FIRST ] 最初の目標     {fmt(plan[0][1])}  (1 コマ 関節 {max_step:g}°・爪 20 までで寄せる)")
     out(f"[FIRST ] 答えの最後の目標 {fmt(a[-1])}  (かかった {policy.latencies[-1]:.2f} 秒)")
     if skip_confirm:
         out("[FIRST ] 始めの確かめは飛ばします (2 回目の試行から)")
@@ -761,7 +795,7 @@ def run_trial(arm, policy, recorder, lo, hi, exec_steps, keys, inp=input, clock=
                 cur_step = chunk_step
                 info["clipped_frames"] += int(cut)
                 last_target = target
-                sent = arm.send(target)
+                sent = send(target)
                 t_sent = clock()
                 if new_chunk and last_model_t is not None:
                     info["gaps"].append(t_sent - last_model_t)
@@ -790,11 +824,11 @@ def run_trial(arm, policy, recorder, lo, hi, exec_steps, keys, inp=input, clock=
                 lt = arm.leader_target()
                 if lt is not None:
                     last_target = lt
-                    sent = arm.send(lt)
+                    sent = send(lt)
                 else:
                     sent = np.asarray(arm.last_sent, dtype=np.float64)
             else:
-                sent = arm.send(last_target)
+                sent = send(last_target)
             extra = {}
             if current is not None:
                 extra["current"] = current
@@ -826,7 +860,9 @@ def run(args):
           f"{'  --rtc: 答えを RTC でつなぐ (依頼 294)' if args.rtc else ''}"
           f"{f'  d の上限 {args.rtc_max_delay} (依頼 295)' if args.rtc_max_delay else ''}"
           + (f"  --blend {args.blend}: 切り替えを {args.blend} コマかけてつなぐ (爪は{'混ぜる' if BLEND_GRIP else '混ぜない'}. 依頼 308)"
-             if args.blend else ""))
+             if args.blend else "")
+          + (f"  --max-step-deg {args.max_step_deg:g}: 関節 5 つの 1 コマの変化を {args.max_step_deg:g}° まで (爪は 20 のまま. 依頼 313)"
+             if args.max_step_deg < MAX_STEP_DEG else ""))
     log_dir = Path(args.log_dir)
     if not log_dir.is_dir():
         sys.exit(f"[ERROR] 記録の置き場所がない: {log_dir}")
@@ -840,14 +876,15 @@ def run(args):
     current_motors = CURRENT_SETS[args.currents] if args.execute else []
     if args.currents != "off":
         print(f"[CURRENT] 1 コマごとに電流を読む: {', '.join(current_motors) or '(ドライランなので読まない)'}")
-    recorder = Recorder(local, f"local/{trial}", current_motors=current_motors, blend=args.blend > 0)
+    recorder = Recorder(local, f"local/{trial}", current_motors=current_motors, blend=args.blend > 0,
+                        max_step=args.max_step_deg)
     arm, info, result, err, reason = None, {}, "", None, ""
     try:
         arm = LiveArm(current_motors) if args.execute else DryArm()
         with KeyReader() as keys:
             info = run_trial(arm, policy, recorder, lo, hi, args.exec_steps, keys, prefetch=not args.no_prefetch,
                              skip_confirm=args.skip_first_confirm, play_speed=args.play_speed, rtc=args.rtc,
-                             rtc_max_delay=args.rtc_max_delay, blend=args.blend)
+                             rtc_max_delay=args.rtc_max_delay, blend=args.blend, max_step=args.max_step_deg)
     except KeyboardInterrupt:
         err = "Ctrl-C"
         print("\n[STOP  ] Ctrl-C で止めました")
@@ -892,7 +929,8 @@ def run(args):
            "jump_max_deg": "" if js["max"] is None else js["max"], "jump_over3": js["over3"],
            "jump_target_median_deg": "" if js_t["median"] is None else js_t["median"],
            "jump_target_max_deg": "" if js_t["max"] is None else js_t["max"], "jump_target_over3": js_t["over3"],
-           "rtc_s_over": info.get("rtc_s_over", 0) if args.rtc else "", "blend": args.blend}
+           "rtc_s_over": info.get("rtc_s_over", 0) if args.rtc else "", "blend": args.blend,
+           "max_step_deg": args.max_step_deg}
     append_trial(log_dir / TRIALS_CSV, row)
     (dst / "trial.json").write_text(json.dumps({**row, "latencies_s": [round(x, 4) for x in policy.latencies],
                                                  "payloads_bytes": policy.payloads,
@@ -908,6 +946,7 @@ def run(args):
                                                  "rtc_sent": policy.rtc_sent, "rtc_echo": policy.rtc_echo,
                                                  "blend_grip": BLEND_GRIP,
                                                  "blend_frames": info.get("blend_frames", 0),
+                                                 "step_clipped_frames": info.get("step_clipped_frames", 0),
                                                  "safe_range": {"lo": lo.tolist(), "hi": hi.tolist()},
                                                  "stopped_by": err}, ensure_ascii=False, indent=2) + "\n")
     print(f"[RECORD] {dst} ({n_files} ファイル) / 1 行 → {log_dir / TRIALS_CSV}")
@@ -923,6 +962,9 @@ def run(args):
               f"最大 {js['max']:.2f}°・{JUMP_OVER:g}° 超 {js['over3']} 回 ({js['n']} 回. 入口の B の前の目標では "
               f"中央値 {js_t['median']:.2f}°・最大 {js_t['max']:.2f}°・{JUMP_OVER:g}° 超 {js_t['over3']} 回)"
               + (f". --blend {args.blend} で混ぜたあとの値 (混ぜたコマ {info.get('blend_frames', 0)})" if args.blend else ""))
+    if args.max_step_deg < MAX_STEP_DEG:
+        print(f"[STEP  ] --max-step-deg {args.max_step_deg:g}: 関節 5 つを {args.max_step_deg:g}° で切ったコマ "
+              f"{info.get('step_clipped_frames', 0)} / {info.get('frames', 0)} (依頼 313)")
     if args.rtc:
         print(f"[RTC   ] d の中央値 {d_med}・s の中央値 {s_med_rtc} (問い合わせ {len(info.get('rtc_d', []))} 回. "
               f"遅れて s > H - d になった回 {info.get('rtc_s_over', 0)}). "
@@ -986,7 +1028,11 @@ def main(argv=None):
                     help="--rtc の d の上限 (1 以上. 既定は答えのコマ数の半分. 依頼 295)")
     ap.add_argument("--blend", type=int, default=0,
                     help=f"答えの切り替えを N コマかけて前の答えと混ぜる (0〜{MAX_BLEND}. 既定 0 = 今までどおり. 依頼 308)")
+    ap.add_argument("--max-step-deg", type=float, default=MAX_STEP_DEG,
+                    help=f"関節 5 つの 1 コマの変化の上限 (度. 1〜{MAX_STEP_DEG:g}. 既定 {MAX_STEP_DEG:g} = 今までどおり. 爪の 20 は変えない. 依頼 313)")
     args = ap.parse_args(argv)
+    if not (math.isfinite(args.max_step_deg) and 1.0 <= args.max_step_deg <= MAX_STEP_DEG):
+        ap.error(f"--max-step-deg は 1〜{MAX_STEP_DEG:g}: {args.max_step_deg:g}")
     if not 0 <= args.blend <= MAX_BLEND:
         ap.error(f"--blend は 0〜{MAX_BLEND}: {args.blend}")
     if args.rtc_max_delay is not None and (not args.rtc or args.rtc_max_delay < 1):
diff --git a/so101/test_run_so101_policy.py b/so101/test_run_so101_policy.py
index 2b25b19..34f167d 100644
--- a/so101/test_run_so101_policy.py
+++ b/so101/test_run_so101_policy.py
@@ -1017,16 +1017,17 @@ def blend_trial(n_frames, blend, keys=None, rtc=False, latency=0.05, exec_steps=
     return arm, pol, rec, info
 
 
-def load_head_module():
-    """依頼 308 の前の版 (git の HEAD) の run_so101_policy.py を別の名前で読む (--blend 0 が前と同じかを比べる)"""
+def load_head_module(rev="b7bf7be"):
+    """依頼 308 の前の版 (git の HEAD) の run_so101_policy.py を別の名前で読む (--blend 0 が前と同じかを比べる).
+    依頼 313 は rev に依頼 313 の前の版を渡す"""
     import importlib.util
     import subprocess
     root = Path(__file__).resolve().parent.parent
-    src = subprocess.run(["git", "-C", str(root), "show", "b7bf7be:so101/run_so101_policy.py"], capture_output=True,
+    src = subprocess.run(["git", "-C", str(root), "show", f"{rev}:so101/run_so101_policy.py"], capture_output=True,
                          text=True, check=True).stdout
-    tmp = Path(tempfile.mkdtemp()) / "run_so101_policy_head.py"
+    tmp = Path(tempfile.mkdtemp()) / f"run_so101_policy_{rev}.py"
     tmp.write_text(src)
-    spec = importlib.util.spec_from_file_location("run_so101_policy_head", tmp)
+    spec = importlib.util.spec_from_file_location(f"run_so101_policy_{rev}", tmp)
     m = importlib.util.module_from_spec(spec)
     spec.loader.exec_module(m)
     return m
@@ -1189,12 +1190,13 @@ class TestBlend(unittest.TestCase):
                     pass
 
             class Rec(RecW):
-                def __init__(self, root, repo_id, current_motors=(), blend=False):
+                def __init__(self, root, repo_id, current_motors=(), blend=False, max_step=None):
                     super().__init__()
                     Path(root).mkdir(parents=True)
                     (Path(root) / "x.txt").write_text("x")
                     self.blend, self.n = blend, 0
                     seen["recorder_blend"] = blend
+                    seen["recorder_max_step"] = max_step
 
                 def add(self, *a, **kw):
                     super().add(*a, **kw)
@@ -1232,20 +1234,182 @@ class TestBlend(unittest.TestCase):
             with open(log_dir / R.TRIALS_CSV) as f:
                 row = list(csv.DictReader(f))[0]
             self.assertEqual(row["blend"], "10")
+            self.assertEqual(row["max_step_deg"], "10.0")                   # 依頼 313: 付けなければ 10
+            self.assertEqual(seen["recorder_max_step"], 10.0)
+            self.assertNotIn("[STEP  ]", txt)
+            self.assertIn("(1 コマ 関節 10°・爪 20 までで寄せる)", txt)
+            log2 = d / "lab" / "LogT2"                                     # 依頼 313: --max-step-deg 4
+            log2.mkdir(parents=True)
+            out = io.StringIO()
+            with unittest.mock.patch.multiple(R, Policy=Pol, DryArm=Arm, Recorder=Rec, KeyReader=Keys, LOCAL_RUNS=d / "runs",
+                                              ask_result=lambda: "success"), \
+                    unittest.mock.patch.object(safe, "check_dataset_root", lambda p: None), \
+                    unittest.mock.patch("sys.stdout", out):
+                R.main(["--log-dir", str(log2), "--raw-dir", str(d / "raw"), "--place", "2", "--blend", "10",
+                        "--max-step-deg", "4", "--skip-first-confirm", "--model", "so101b"])
+            txt = out.getvalue()
+            self.assertEqual(seen["recorder_max_step"], 4.0)
+            self.assertIn("--max-step-deg 4: 関節 5 つの 1 コマの変化を 4° まで (爪は 20 のまま. 依頼 313)", txt)
+            self.assertIn("(1 コマ 関節 4°・爪 20 までで寄せる)", txt)
+            self.assertIn("[STEP  ] --max-step-deg 4: 関節 5 つを 4° で切ったコマ ", txt)
+            self.assertIn("[JUMP  ]", txt)
+            tj = json.loads(next((log2 / "so101").glob("*/trial.json")).read_text())
+            self.assertEqual(tj["max_step_deg"], 4.0)
+            self.assertGreater(tj["step_clipped_frames"], 0)
+            self.assertLessEqual(max(tj["switch_jumps_sent_deg"]), 4.0)
+            with open(log2 / R.TRIALS_CSV) as f:
+                self.assertEqual(list(csv.DictReader(f))[0]["max_step_deg"], "4.0")
 
     def test_csv_has_blend_last(self):
-        self.assertEqual(R.TRIAL_COLUMNS[-1], "blend")
+        self.assertEqual(R.TRIAL_COLUMNS[-2], "blend")                      # 依頼 313 で max_step_deg がその後ろに
         with tempfile.TemporaryDirectory() as d:
             p = Path(d) / R.TRIALS_CSV
-            old = R.TRIAL_COLUMNS[:-1]                                      # 依頼 307 までの見出し
+            old = R.TRIAL_COLUMNS[:-2]                                      # 依頼 307 までの見出し
             p.write_text(",".join(old) + "\n")
             R.append_trial(p, {"trial": "a", "rtc_s_over": "", "blend": 10})
             with open(p) as f:
                 rows = list(csv.reader(f))
             self.assertEqual(rows[0], old)
-            self.assertEqual(rows[1][-1], "10")
+            self.assertEqual(rows[1][-2], "10")
             self.assertEqual(len(rows[1]), len(R.TRIAL_COLUMNS))
 
 
+def ms_trial(n_frames, max_step=None, blend=0, keys=None, rtc=False, exec_steps=None, policy=None, rec=None, mod=R):
+    """依頼 313: --max-step-deg を付けて (None なら付けずに) 先に問い合わせる形を偽の時計で回す"""
+    clk = FakeClock()
+    arm, rec = FakeArm(), rec or RecW()
+    pol = policy or PolicyJump()
+    kw = {"blend": blend}
+    if max_step is not None:
+        kw["max_step"] = max_step
+    with unittest.mock.patch.object(mod, "ThreadPoolExecutor", lambda max_workers: ClockExecutor(clk, 0.05)):
+        info = mod.run_trial(arm, pol, rec, LO, HI, exec_steps, keys or FakeKeys({n_frames: "q"}), inp=lambda p: "",
+                             clock=clk, sleep=clk.sleep, out=lambda *a: None, prefetch=True, skip_confirm=True, rtc=rtc, **kw)
+    return arm, pol, rec, info
+
+
+class TestMaxStep(unittest.TestCase):
+    """依頼 313: --max-step-deg X (関節 5 つの 1 コマの変化の上限. 1〜10. 既定 10 = 今までどおり)"""
+
+    PREV = "c123ea8"                                                        # 依頼 313 の前の版
+
+    def test_step_clip(self):
+        last = np.array([0, 0, 0, 0, 0, 10], dtype=np.float64)
+        t, cut = R.step_clip([10, -10, 2, -3, 4, 90], last, 4.0)
+        np.testing.assert_allclose(t, [4, -4, 2, -3, 4, 90])                 # 爪はそのまま (爪の 20 は入口の B)
+        self.assertTrue(cut)
+        t, cut = R.step_clip([1, -1, 2, -3, 4, 90], last, 4.0)
+        np.testing.assert_allclose(t, [1, -1, 2, -3, 4, 90])
+        self.assertFalse(cut)
+
+    def test_limit_works(self):
+        arm, _, rec, info = ms_trial(80, max_step=4.0)
+        sent = np.array(arm.sent)
+        steps = np.abs(np.diff(np.vstack([np.zeros(6), sent]), axis=0))
+        self.assertLessEqual(steps[:, :5].max(), 4.0 + 1e-9)                # 関節 5 つは 1 コマ 4° まで
+        self.assertGreater(steps[:, 5].max(), 4.0)                          # 爪は切らない (0 ↔ 50)
+        self.assertGreater(info["step_clipped_frames"], 0)
+        self.assertEqual(info["max_step_deg"], 4.0)
+        self.assertLessEqual(max(info["jumps"]), 4.0 + 1e-9)                # 切り替えの跳びは切ったあとの送った値で数える
+        self.assertGreater(max(info["jumps_target"]), 4.0)                  # B の前の目標は切らない (記録の action と同じ位置づけ)
+        cut = [r for r in rec.rows if np.max(np.abs(r["action"][:5] - r["sent"][:5])) > 1e-9]
+        self.assertEqual(len(cut), info["step_clipped_frames"])             # action は切る前・sent は切ったあと
+        a10, _, _, i10 = ms_trial(80)
+        self.assertGreater(np.abs(np.diff(np.array(a10.sent)[:, :5], axis=0)).max(), 4.0)     # 付けなければ切らない
+        self.assertEqual(i10["step_clipped_frames"], 0)
+
+    def test_after_blend(self):                                             # 混ぜたあとの値に当てる
+        arm, _, rec, info = ms_trial(80, max_step=3.0, blend=10)
+        self.assertGreater(info["blend_frames"], 0)
+        steps = np.abs(np.diff(np.vstack([np.zeros(6), np.array(arm.sent)]), axis=0))
+        self.assertLessEqual(steps[:, :5].max(), 3.0 + 1e-9)
+        self.assertTrue(any(r["blend_w"] for r in rec.rows))
+
+    def test_pause_and_correct_also_limited(self):                          # 入口の B と同じく手直し・一時停止のコマにも当てる
+        keys = FakeKeys({20: " ", 21: "t", 40: "q"})
+        arm, _, rec, info = ms_trial(40, max_step=2.0, keys=keys)
+        self.assertIn(R.CORRECT, rec.modes)
+        steps = np.abs(np.diff(np.vstack([np.zeros(6), np.array(arm.sent)]), axis=0))
+        self.assertLessEqual(steps[:, :5].max(), 2.0 + 1e-9)
+
+    def test_default_and_10_same_as_before(self):
+        H = load_head_module(self.PREV)
+        for kw in ({}, {"blend": 10}, {"rtc": True, "policy_h": 30}, {"exec_steps": 6, "blend": 5}):
+            for ms in (None, 10.0):
+                res = []
+                for mod in (H, R):
+                    pol = PolicyJump(horizon=kw.get("policy_h", R.HORIZON))
+                    res.append(ms_trial(70, max_step=None if mod is H else ms, blend=kw.get("blend", 0),
+                                        rtc=kw.get("rtc", False), exec_steps=kw.get("exec_steps"), policy=pol, mod=mod))
+                (a0, p0, r0, i0), (a1, p1, r1, i1) = res
+                np.testing.assert_array_equal(np.array(a0.sent), np.array(a1.sent))
+                self.assertEqual(len(r0.rows), len(r1.rows))
+                for x, y in zip(r0.rows, r1.rows):
+                    for k in ("chunk_step", "chunk_id", "mode", "blend_w"):
+                        self.assertEqual(x[k], y[k])
+                    np.testing.assert_array_equal(x["action"], y["action"])
+                    np.testing.assert_array_equal(x["sent"], y["sent"])
+                self.assertEqual(set(i1) - set(i0), {"max_step_deg", "step_clipped_frames"})
+                for k in i0:
+                    self.assertEqual(i0[k], i1[k], k)
+                self.assertEqual(i1["max_step_deg"], 10.0)
+                self.assertEqual(i1["step_clipped_frames"], 0)
+                self.assertEqual(len(p0.obs), len(p1.obs))
+                for o0, o1 in zip(p0.obs, p1.obs):
+                    self.assertEqual(sorted(o0), sorted(o1))
+                    for k in o0:
+                        if isinstance(o0[k], np.ndarray):
+                            np.testing.assert_array_equal(o0[k], o1[k])
+
+    def test_features(self):
+        H = load_head_module(self.PREV)
+        self.assertEqual(R.dataset_features(), H.dataset_features())
+        self.assertEqual(R.dataset_features((), True), H.dataset_features((), True))
+        self.assertNotIn("ptm.max_step_deg", R.dataset_features((), False, False))
+        self.assertIn("ptm.max_step_deg", R.dataset_features((), False, True))
+
+    def test_lerobot_max_step_column(self):                                 # 10 より小さいときだけ ptm.max_step_deg を書く
+        from lerobot.datasets.lerobot_dataset import LeRobotDataset
+        img = np.zeros((R.CAM_H, R.CAM_W, 3), dtype=np.uint8)
+        with tempfile.TemporaryDirectory() as d:
+            for ms, has in ((4.0, True), (10.0, False), (None, False)):
+                root = Path(d) / "local" / f"ms_{ms}"
+                rec = R.Recorder(root, f"local/ms_{ms}", max_step=ms)
+                for i in range(3):
+                    rec.add(np.zeros(6), img, img, np.zeros(6), np.zeros(6), R.MODEL, i, 0, t_wall=1000.0 + i)
+                rec.close()
+                ds = LeRobotDataset(f"local/ms_{ms}", root=root)
+                self.assertEqual("ptm.max_step_deg" in ds.features, has, ms)
+                if has:
+                    self.assertEqual(float(np.asarray(ds.hf_dataset[0]["ptm.max_step_deg"]).reshape(-1)[0]), 4.0)
+
+    def test_run_trial_rejects_looser(self):
+        for bad in (10.5, 0.0, -1.0):
+            with self.assertRaises(ValueError):
+                ms_trial(10, max_step=bad)
+
+    def test_args(self):
+        with unittest.mock.patch.object(R, "run", lambda a: a.max_step_deg):
+            self.assertEqual(R.main(["--log-dir", "/tmp"]), 10.0)
+            self.assertEqual(R.main(["--log-dir", "/tmp", "--max-step-deg", "4"]), 4.0)
+            self.assertEqual(R.main(["--log-dir", "/tmp", "--max-step-deg", "1"]), 1.0)
+            self.assertEqual(R.main(["--log-dir", "/tmp", "--max-step-deg", "10"]), 10.0)
+        for bad in ("10.5", "11", "0.5", "0", "-3", "nan", "inf", "x"):
+            with self.assertRaises(SystemExit), unittest.mock.patch("sys.stderr", io.StringIO()):
+                R.main(["--log-dir", "/tmp", "--max-step-deg", bad])
+
+    def test_csv_last_column(self):
+        self.assertEqual(R.TRIAL_COLUMNS[-1], "max_step_deg")
+        with tempfile.TemporaryDirectory() as d:
+            p = Path(d) / R.TRIALS_CSV
+            old = R.TRIAL_COLUMNS[:-1]                                      # 依頼 312 までの見出し
+            p.write_text(",".join(old) + "\n")
+            R.append_trial(p, {"trial": "a", "blend": 10, "max_step_deg": 4.0})
+            with open(p) as f:
+                rows = list(csv.reader(f))
+            self.assertEqual(rows[0], old)
+            self.assertEqual(rows[1][-2:], ["10", "4.0"])
+
+
 if __name__ == "__main__":
     unittest.main()
diff --git a/test_lab_start.sh b/test_lab_start.sh
index e3e7205..5b227cb 100755
--- a/test_lab_start.sh
+++ b/test_lab_start.sh
@@ -643,7 +643,7 @@ check "--serve-only でも空打ちまで行う (依頼 176)" 'has out.txt "===
 check "Pod は消さない (DELETE を呼ばない) で, かかった時間と片付け方を出す" '[ $(n_call DELETE) = 0 ] && has out.txt "=== かかった時間" && has out.txt "Pod は残しています (id $ID_NEW). 片付けは ./lab_stop.sh --log LogT"'
 check "記録 lab_start_*.txt に残る・始めの行に --serve-only と出る" 'grep -qF "サーバーとトンネルだけ (--serve-only" "$T/data/lab/LogT"/lab_start_*.txt'
 rm -rf "$T"
-check "--help に --serve-only・--grip-value・--flow / --speed・5b の空打ちの説明が入る (2〜86 行 (依頼 289 で so101b の 3 行, 依頼 294 で --rtc の 3 行, 依頼 307 で so101c の 3 行, 依頼 308 で --blend の 2 行, 依頼 309 で so101d の 3 行が増えた))" 'sed -n "2,86p" "$HERE/lab_start.sh" | grep -qF -- "--serve-only  Pod を作って" && sed -n "2,86p" "$HERE/lab_start.sh" | grep -qF -- "--no-tilt-fix  傾きを" && sed -n "2,86p" "$HERE/lab_start.sh" | grep -qF -- "--grip-value N  爪の閉じる値" && sed -n "2,86p" "$HERE/lab_start.sh" | grep -qF -- "--flow / --speed N  run_policy_client.py に" && sed -n "2,86p" "$HERE/lab_start.sh" | grep -qF -- "# 5b. 空打ち" && grep -qF "sed -n '"'"'2,86p'"'"'" "$HERE/lab_start.sh"'
+check "--help に --serve-only・--grip-value・--flow / --speed・5b の空打ちの説明が入る (2〜88 行 (依頼 289 で so101b の 3 行, 依頼 294 で --rtc の 3 行, 依頼 307 で so101c の 3 行, 依頼 308 で --blend の 2 行, 依頼 309 で so101d の 3 行, 依頼 313 で --max-step-deg の 2 行が増えた))" 'sed -n "2,88p" "$HERE/lab_start.sh" | grep -qF -- "--serve-only  Pod を作って" && sed -n "2,88p" "$HERE/lab_start.sh" | grep -qF -- "--no-tilt-fix  傾きを" && sed -n "2,88p" "$HERE/lab_start.sh" | grep -qF -- "--grip-value N  爪の閉じる値" && sed -n "2,88p" "$HERE/lab_start.sh" | grep -qF -- "--flow / --speed N  run_policy_client.py に" && sed -n "2,88p" "$HERE/lab_start.sh" | grep -qF -- "# 5b. 空打ち" && grep -qF "sed -n '"'"'2,88p'"'"'" "$HERE/lab_start.sh"'
 
 echo "== 空打ち (依頼 176): トンネルのあと・アームの前に 1 回. 失敗しても止めずに続ける"
 setup; state $ID_OLD; pod 200 "$RUNNING"; probe 1 1 1 1 1; run
@@ -954,6 +954,42 @@ check "so101c つなぎ直し --blend 10: RTC なしのサーバーをそのま
 rm -rf "$T"
 check "--help に --blend の説明が入る (依頼 308)" './lab_start.sh --help | grep -qF -- "--blend N (so101a〜so101d. 0〜15. 依頼 308)"'
 
+# ---- 依頼 313: --max-step-deg X をクライアントにそのまま渡す ----
+so101_setup; run --model so101b --blend 10 --max-step-deg 4
+check "so101b --blend 10 --max-step-deg 4: クライアントに両方渡し, [SO101] で出す (空打ちには渡さない)" '[ $RC = 0 ] && grep -q -- "so101/run_so101_policy.py .* --model so101b .* --step 2999 --blend 10 --max-step-deg 4$" "$T/py.log" && ! grep -q -- "--warmup.*--max-step-deg" "$T/py.log" && has out.txt "[SO101 ] 1 コマの変化の上限: 関節 5 つ 4° (--max-step-deg 4"'
+rm -rf "$T"
+so101c_setup; run --model so101c
+check "既定では --max-step-deg を渡さず [SO101] の上限の行も出さない (依頼 313)" '[ $RC = 0 ] && ! has py.log "--max-step-deg" && ! has out.txt "1 コマの変化の上限:"'
+rm -rf "$T"
+for m in so101a so101c; do
+    if [ $m = so101a ]; then so101_setup; else so101c_setup; fi
+    run --model $m --max-step-deg 3.5 --exec-steps 8
+    check "$m --max-step-deg 3.5: クライアントにそのまま渡す" '[ $RC = 0 ] && grep -q -- "so101/run_so101_policy.py .* --model $m .* --exec-steps 8 --max-step-deg 3.5$" "$T/py.log"'
+    rm -rf "$T"
+done
+so101d_setup() { so101_setup; mkdir -p "$T/data/datasets/so101_redblock_box_ideal_x13_only_v1/raw_episodes"; }
+so101d_setup; run --model so101d --rtc --max-step-deg 10
+check "so101d --rtc --max-step-deg 10: 10 も受けてそのまま渡す" '[ $RC = 0 ] && grep -q -- "--model so101d .* --step 2999 --rtc --max-step-deg 10$" "$T/py.log"'
+rm -rf "$T"
+for bad in 11 10.5 10.01 0 0.5 0.999 -3 x 4. .5 "" 3e0; do
+    so101c_setup; run --model so101c --max-step-deg "$bad"
+    check "--max-step-deg '$bad' は受けない (終了コード 2・API を呼ばない. 依頼 313)" '[ $RC = 2 ] && [ ! -s "$T/calls.log" ] && has out.txt "--max-step-deg"'
+    rm -rf "$T"
+done
+so101c_setup; run --model so101c --max-step-deg 4.125
+check "--max-step-deg 4.125 (小数 3 桁) も受けてそのまま渡す (codex R1 ❌)" '[ $RC = 0 ] && grep -q -- "--step 2999 --max-step-deg 4.125$" "$T/py.log"'
+rm -rf "$T"
+so101c_setup; run --model so101c --max-step-deg
+check "--max-step-deg に値がなければ止まる (依頼 313)" '[ $RC = 2 ] && [ ! -s "$T/calls.log" ] && has out.txt "--max-step-deg には 1〜10 の数を付ける"'
+rm -rf "$T"
+setup; run --max-step-deg 4
+check "mechArm の --model に --max-step-deg は付けられない (依頼 313)" '[ $RC = 2 ] && [ ! -s "$T/calls.log" ] && has out.txt "--max-step-deg は --model so101a〜so101d だけ"'
+rm -rf "$T"
+so101_setup; state $ID_OLD; pod 200 "$RUNNING"; probe 1 1 1 1 1; serve_dir /workspace/ckpt/so101_teleop_even_h30_v1_2999; run --model so101b --blend 10 --max-step-deg 4
+check "so101b つなぎ直し --blend 10 --max-step-deg 4: 今のサーバーをそのまま使い (起動し直さない), クライアントに渡す" '[ $RC = 0 ] && ! has ssh.log "tmux new" && [ $(n_call POST) = 0 ] && grep -q -- "--model so101b .* --step 2999 --blend 10 --max-step-deg 4$" "$T/py.log"'
+rm -rf "$T"
+check "--help に --max-step-deg の説明が入る (依頼 313)" './lab_start.sh --help | grep -qF -- "--max-step-deg X (so101a〜so101d. 1〜10. 依頼 313)"'
+
 echo "== so101d (依頼 309): so101c と同じ流れで, 理想の道だけで学習したモデル"
 so101d_setup() { so101_setup; mkdir -p "$T/data/datasets/so101_redblock_box_ideal_x13_only_v1/raw_episodes"; }
 so101d_setup; run --model so101d
