03 / 90

第 03: 回復演習:壊れた環境を診断する

回復演習:壊れた環境を診断する。各活動で予測・観察・振り返り・回復の証拠を残します。

自律学習手法と Python エンジニアリング基礎 480 分(8 時間の集中学習)
01 120 分

回復演習:壊れた環境を診断する

独立習得チェック — 評価対象の作業中に AI の支援は受けられません。支援を受けた場合は誠実に申告することが必須ですが、支援を受けた作業はあくまで復習扱いです。習得を主張する前に、新しい無支援チェックを完了してください。

前提条件

デイ 02 の活動の修了。評価対象の経路には Bash が必要です。検証済みの実行範囲は Linux Bash です。動作する `python3` が必要です。インストールもマシン全体の変更も不要です。

学習目標

意図的に壊した仮想環境またはパスの前提を、予測・最小再現・復習ノートで診断する。

手順

この演習では、使い捨ての env-drill ディレクトリ内に、意図的に壊れた無害なフィクスチャを用意します。実行前に症状を予測し、再現し、診断証拠を集め、正当化できる最小の修正を適用して、再チェックしてください。フィクスチャのディレクトリ内に留まり、マシン全体の変更は行いません(インストール、env-drill 外の編集、永続的な環境変更は禁止。下記の修正は1回のコマンド呼び出しに限定されています)。 各ブロックはフェイルストップのサブシェル内で実行します。セットアップは mktemp の新しい専用ルートを検証し、失敗時は書き込み前に中断します。周囲の Python 設定がすでに helper を解決できるかを、実行しない importlib.util.find_spec チェックで確認し、解決できる場合も中断します(意図した失敗にはその前提が必要で、このプローブはモジュールをインポートも実行もしません)。最後のブロックは、作成したルートを正確に指すリテラルな rm -r -- <private-root> 後片付け行を表示します。後続ブロックの前に表示された export SBX_ROOT= 行を貼り付け、シェル本来の PYTHONPATH の有無と値を記録してください。未設定・空・非空のどれでも有効な証拠です。 これらのブロックは Bash で実行してください。表示される export/rm -r -- 行は Bash の %q クォートを使い、検証済みの範囲は Linux Bash です。zsh/dash/Windows は未検証です。

演習と予測記録

壊れたフィクスチャを作成し、失敗を再現します(ブロック全体を貼り付けます。セットアップに失敗した場合、または実行しないチェックで helper が既に解決可能と判明した場合は、書き込み前に中断します):

(
set -e
SBX_ROOT=$(mktemp -d "${TMPDIR:-/tmp}/d03env.XXXXXX")
[ -n "$SBX_ROOT" ]
[ -d "$SBX_ROOT" ]
[ -w "$SBX_ROOT" ]
[ -x "$SBX_ROOT" ]
probe_rc=0
python3 -c "import sys, importlib.util
try:
    spec = importlib.util.find_spec('helper')
except Exception:
    sys.exit(4)
sys.exit(3 if spec is not None else 0)" || probe_rc=$?
if [ "$probe_rc" -ne 0 ]; then
  if [ "$probe_rc" -eq 3 ]; then
    echo "abort: ambient Python config already resolves 'helper' - the intended failure cannot be demonstrated"
  else
    echo "abort: helper-resolvability probe failed (rc=$probe_rc) - cannot verify the precondition safely"
  fi
  exit 1
fi
mkdir "$SBX_ROOT/env-drill"
cd "$SBX_ROOT/env-drill"
mkdir tools
printf 'def greet():\n    return "ok"\n' > tools/helper.py
printf 'from helper import greet\nprint(greet())\n' > app.py
rc=0
python3 app.py 2>err.txt || rc=$?
cat err.txt
grep -q "ModuleNotFoundError: No module named 'helper'" err.txt
echo "expected failure observed (rc=$rc)"
printf 'export SBX_ROOT=%q\n' "$SBX_ROOT"
)

実行前にエラーを予測します。表示された export SBX_ROOT= 行を貼り付けてから証拠を集めます:

(
set -e
: "${SBX_ROOT:?run the setup block first, then paste its printed export line}"
[ -d "$SBX_ROOT/env-drill" ]
cd "$SBX_ROOT/env-drill"
python3 -c "import sys, os; print([os.path.abspath(p or '.') for p in sys.path])"
ls tools
)

この呼び出しに限定した、正当化できる最小の修正を適用して再チェックします。記録した元の値と PYTHONPATH を比較します——ブロックは set/unset マーカーと値を明示的に表示するため、未設定・空・非空のいずれの元の状態も「変わっていない」証拠として区別できます:

(
set -e
: "${SBX_ROOT:?run the setup block first, then paste its printed export line}"
[ -d "$SBX_ROOT/env-drill" ]
cd "$SBX_ROOT/env-drill"
pp_state() { if [ "${PYTHONPATH+x}" = x ]; then printf 'PYTHONPATH %s: set value=<%s>\n' "$1" "$PYTHONPATH"; else printf 'PYTHONPATH %s: unset\n' "$1"; fi }
pp_state before
PYTHONPATH=tools python3 app.py
pp_state after
printf 'rm -r -- %q\n' "$SBX_ROOT"
)

症状・証拠・修正・最小である理由・再チェック結果を記録してください。

独立習得基準

無支援で以下を満たした場合に合格:(a) 実行前に `ModuleNotFoundError` の症状を予測した。(b) 診断証拠(`tools/` が含まれない解決済み `sys.path` の一覧と、ファイルの存在を示す `ls tools` の結果)を記録した。(c) 適用した修正が1回の呼び出しに限定され、最小である理由を文書化した。(d) 成功した再チェックと非永続性の確認を記録した — スコープ付き修正後の `PYTHONPATH` が記録した元の値(未設定・空・不変の非空)と一致する。支援は復習扱いのみであり、習得を主張する前に新しい無支援チェックが必要です。

公式ソースリソースと権利証跡

linking PSF License Version 2

The Python Tutorial: Virtual Environments and Packages

著者・提供機関: Python Software Foundation | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Section 12 (creating venvs, pip installs, requirements files)

検証バージョンと日付: Python 3.12 (Verified: 2026-10-30)

選定理由:

Primary reference for python -m venv, interpreter isolation, and requirements files used by the wrong-environment drills.

ソース前提知識:

Basic Python syntax from Study Days 01-09

安全フォールバック(オフライン回復性):

The drill needs no network: venv creation, sys.executable inspection, and ModuleNotFoundError reproduction all run offline.

比較対象候補リソースと選定評価 (2)
pip documentation ↗ compared_alternative [MIT]

Primary reference for pip commands, but the tutorial presents the create-activate-install loop as one beginner-friendly narrative.

virtualenv documentation ↗ compared_alternative [MIT License]

Mature third-party environment tool with overlapping behavior; the stdlib venv tutorial was selected to avoid an extra dependency for first-time setup.

linking PSF License Version 2

The Python Tutorial: Errors and Exceptions

著者・提供機関: Python Software Foundation | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Sections 8.3-8.6 (handling exceptions, else, finally, cleanup actions)

検証バージョンと日付: Python 3.12 (Verified: 2026-10-30)

選定理由:

Primary reference for try/except/else/finally semantics and the with statement as predefined cleanup for Day 11.

ソース前提知識:

Basic Python syntax from Study Days 01-09

安全フォールバック(オフライン回復性):

Every clause behavior in the lesson is demonstrated by runnable local snippets.

比較対象候補リソースと選定評価 (2)
MIT OCW 6.0001 Lecture on Exceptions ↗ compared_alternative [CC BY-NC-SA 4.0]

Solid lecture treatment but paced for a semester course and requires video viewing; the tutorial section matches the exercise scope directly.

Python Standard Library: Built-in Exceptions ↗ compared_alternative [PSF License Version 2]

Reference-style exception hierarchy listing rather than the tutorial narrative; retained as lookup material for the recovery drills.

02 120 分

エージェント支援エンジニアリングのレビューと修正

エージェント支援エンジニアリングチェック — 選択トラック・権限・レビュー境界を宣言します。エージェントの出力は独立した証拠ではありません。認可されたツールが使えない場合、実演部分は「ブロック済み・未実行」と記録してください。下記の事前作成バグ入りパッチはオフライン例示であり、実際のプロバイダーの出力として観測されたものではありません。

前提条件

day-03-act-01 の修了と、選択済みのエージェントツールトラック。

学習目標

エージェントが生成した変更をレビューし、チェックを実行して失敗を特定し、出力を鵜呑みにせず修正を要求する。

手順

新しい agent-review-sandbox 内で、def add(a, b): return a + b を含む calc.py と、下記の独立チェック check_clamp.py(エージェントの主張とは独立した自分のチェック)を作成します。次に選択したエージェントに正確にこの変更を依頼します:「agent-review-sandbox/calc.py に、x を [lo, hi] の範囲に制限して返し、lo > hi のとき ValueError を送出する関数 clamp(x, lo, hi) を追加してください。add や他のファイルは変更しないでください」。書き込み前の承認を必須とし、サンドボックス外の操作は禁止です。 宣言した権限は契約であって OS サンドボックスではありません。範囲は自分で検証してください。 予算:エージェントのターンまたは再試行は最大3回。停止条件:チェック合格、予算枯渇、または範囲外操作の発生。初回実行で合格した場合はそれが有効な証拠です。欠陥を捏造せず、合格出力を記録し、実質的なレビューを完了してください。ラベル付きドリルパッチは別途、修正ループの練習に使えます(ドリル証拠として記録)。生成されたコードに対して自分のチェックを実行してください。認可されたツールがない場合は、参考解答のラベル付き事前作成パッチでループを練習してください。これは例示であり、実演の証拠ではありません。

演習と予測記録

独立した動作チェック(自分で書き、check_clamp.py として保存):

from calc import clamp
assert clamp(5, 0, 10) == 5
assert clamp(-3, 0, 10) == 0
assert clamp(99, 0, 10) == 10
try:
    clamp(2, 10, 0)
except ValueError:
    pass
else:
    raise AssertionError('clamp must reject lo > hi')
print('clamp checks passed')

生成されたコードに対して python3 check_clamp.py を実行します。失敗した場合は、正確なフィードバック(どのケースか、期待値と実際値、疑われる原因)を書き、修正を依頼し、差分(git diff または保存したコピーとの diff -u)を記録し、チェックを再実行します。記録するもの:失敗出力、自分のフィードバック、差分、合格した再チェック。初回で合格した場合は、合格出力と実質的な証拠レビュー(各 assert の追跡、lo > hi の ValueError 経路の検証、add など他ファイルの未変更確認)を記録します。ラベル付きドリルパッチでフィードバックの練習は可能ですが、ドリル証拠として記録し、エージェント出力にはしません。

独立習得基準

以下を満たした場合に合格:(a) 学習者が作成した `check_clamp.py` が存在し、生成コードに対して実行された。(b) 実際の失敗経路(失敗出力・失敗ケースと期待値/実際値・疑われる原因を指名したフィードバック・修正差分・合格した再チェック)が記録されている、または初回合格が記録されている(合格出力+各チェック・`lo > hi` 経路・範囲遵守を追跡した実質的な証拠レビュー)。有効な結果を改ざんしてエージェントの欠陥を捏造してはならず、ラベル付きドリルパッチはその旨記録した任意の練習証拠です。認可されたツールがない場合、実演部分はブロック済み・未実行と記録され、ループはラベル付き例示で実演される。例示を実際のエージェント出力として提示してはいけません。

公式ソースリソースと権利証跡

linking Open Access / CC BY 4.0

SWE-agent: Agent-Computer Interfaces Enable Automated Software Engineering

著者・提供機関: John Yang, Carlos E. Jimenez, Alexander Wettig, Kilian Lieret, Shunyu Yao, Karthik Narasimhan, Ofir Press | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Section 2 The Agent-Computer Interface and Section 3 SWE-agent: Designing an ACI for Software Engineering

検証バージョンと日付: NeurIPS 2024 / arXiv:2405.15793v2 (Verified: 2026-10-30)

選定理由:

Primary literature on agent-computer interfaces showing that bounded tool commands, trajectory inspection, and environment constraints determine whether an agent can carry an engineering task to verifiable completion.

ソース前提知識:

Agent loops, tool protocols, and basic software engineering workflow vocabulary.

安全フォールバック(オフライン回復性):

The permission/budget control profile, tool contract schema, and trace audit procedure are fully implemented in the local bounded agent fixture (projects/agent_learning).

比較対象候補リソースと選定評価 (2)

Broader generalist agent platform; SWE-agent isolates the agent-computer interface design principles most relevant to bounded task delivery.

AutoCodeRover: Autonomous Program Improvement ↗ compared_alternative [Open Access / CC BY 4.0]

Focuses on autonomous program repair via code search; SWE-agent better matches the curriculum's bounded-tool and human-verification emphasis.

linking Open Access / CC BY 4.0

Reflexion: Language Agents with Verbal Reinforcement Learning

著者・提供機関: Noah Shinn, Federico Cassano, Ashwin Gopinath, Karthik Narasimhan, Shunyu Yao | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Section 2 & 3 (Reflexion Architecture and Memory Buffer)

検証バージョンと日付: NeurIPS 2023 / arXiv:2303.11366v4 (Verified: 2026-10-30)

選定理由:

Rigorous framework analyzing dynamic error feedback, memory buffering of execution failures, and controlled self-reflection loops without updating model weights.

ソース前提知識:

Reinforcement learning concepts, agent evaluation loops, and error feedback handling.

安全フォールバック(オフライン回復性):

Error recovery state diagrams and retry budget algorithms are detailed in curriculum materials.

比較対象候補リソースと選定評価 (2)

Single-turn generative text refinement; Reflexion operates across multi-turn external environment action-observation failures.

Domain-specific LLM-based agent for open-world Minecraft; Reflexion establishes domain-general verbal feedback control loops.

03 120 分

独立習得:ファイルシステム成果物チェック

独立習得チェック — 評価対象の作業中に AI の支援は受けられません。支援を受けた場合は誠実に申告することが必須ですが、支援を受けた作業はあくまで復習扱いです。習得を主張する前に、新しい無支援チェックを完了してください。

前提条件

day-03-act-02 の修了。評価対象の経路には Bash が必要です。検証済みの実行範囲は Linux Bash です。

学習目標

新しいタスクと検査可能な成果物で、端末/ファイルシステムの独立した習得を示す。

手順

新しい転移タスクです — デイ 02 の手順の繰り返しではありません。各チェックを実行する前に予測を書き、観測出力を記録してください。すべて新しい使い捨ての report-sandbox 内で行い、その外には一切触れません。 ブロックはフェイルストップのサブシェル内で実行します。先に mktemp の新しい専用ルートを検証し、mkdir/cd の失敗は書き込み前に中断します。現在のディレクトリに書き込むことはありません。末尾には、作成した専用ルートだけを正確に指すリテラルな rm -r -- <private-root> 後片付けコマンド(Bash %q クォート)が表示されます。そのディレクトリを削除したい場合のみ実行してください。 ブロックは Bash で実行してください。検証済みの範囲は Linux Bash で、zsh/dash/Windows は未検証です。

演習と予測記録

下のブロック全体を新しい Bash シェルで(1ブロックとして)実行し、各 wc、diff、find の前に予測を書きます。セットアップに失敗した場合、サブシェルが中断し、現在のディレクトリには何も書き込まれません。末尾には、作成したルートだけを指すリテラルな rm -r -- <private-root> 後片付けコマンドが表示されます。削除したい場合のみ実行してください:

(
set -e
SBX_ROOT=$(mktemp -d "${TMPDIR:-/tmp}/d03rpt.XXXXXX")
[ -n "$SBX_ROOT" ]
[ -d "$SBX_ROOT" ]
[ -w "$SBX_ROOT" ]
[ -x "$SBX_ROOT" ]
mkdir "$SBX_ROOT/report-sandbox"
cd "$SBX_ROOT/report-sandbox"
mkdir data archive
printf 'month,total\njan,10\nfeb,20\n' > data/sales-q1.csv
wc -l data/sales-q1.csv
cp data/sales-q1.csv archive/sales-q1.bak
diff data/sales-q1.csv archive/sales-q1.bak
printf 'draft note\n' > data/readme.txt
mv data/readme.txt archive/notes.txt
find . -type f | sort
printf 'rm -r -- %q\n' "$SBX_ROOT"
)

満たすべき成果物チェック:バックアップが元ファイルとバイト単位で同一。移動後に data/readme.txt が存在しない。最終の find 出力が ./archive/notes.txt、./archive/sales-q1.bak、./data/sales-q1.csv の3つだけを列挙する。

独立習得基準

無支援で以下を満たした場合に合格:(a) 各 `wc`/`diff`/`find` の前に予測を書き、観測出力を記録した。(b) 3つの成果物チェックすべてが成立 — `diff` 結果が同一、`data/` に `readme.txt` がない、正確な3ファイルの `find` 一覧。(c) 作業が `report-sandbox` 内に留まった。支援は復習扱いのみであり、習得を主張する前に新しい無支援チェックが必要です。

公式ソースリソースと権利証跡

linking PSF License Version 2

Python Standard Library: pathlib

著者・提供機関: Python Software Foundation | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Path.exists, Path.cwd, and anchoring paths to __file__

検証バージョンと日付: Python 3.12 (Verified: 2026-10-30)

選定理由:

Normative reference for the exists()/cwd() evidence that separates an absent file from a wrong working directory.

ソース前提知識:

Basic Python syntax from Study Days 01-09

安全フォールバック(オフライン回復性):

Path.exists() and Path.cwd() are exercised directly in the local drill, so no online page is required.

比較対象候補リソースと選定評価 (2)
os.path documentation ↗ compared_alternative [PSF License Version 2]

Functionally equivalent for exists() checks; pathlib keeps the beginner syntax object-oriented and consistent across the block.

shutil — High-level file operations ↗ compared_alternative [PSF License Version 2]

Covers copying and moving whole trees rather than path modeling; pathlib remains the right reference for the filesystem checks these days rehearse.

linking PSF License Version 2

Python Standard Library: tempfile

著者・提供機関: Python Software Foundation | オリジナル出所URL ↗

該当セクション・タイムスタンプ: TemporaryDirectory for disposable on-disk fixtures

検証バージョンと日付: Python 3.12 (Verified: 2026-10-30)

選定理由:

Normative reference for creating and auto-removing fixture files inside tests without touching real user files.

ソース前提知識:

Basic Python syntax from Study Days 01-09

安全フォールバック(オフライン回復性):

TemporaryDirectory is part of the installed standard library and needs no page access.

比較対象候補リソースと選定評価 (2)
pytest tmp_path fixture ↗ compared_alternative [MIT]

Equivalent capability scoped to the pytest runner; deferred until the curriculum adopts pytest.

io — Core tools for working with streams ↗ compared_alternative [PSF License Version 2]

Lower-level file-object interface without automatic cleanup semantics; tempfile was selected for the safe scratch-file pattern the drills require.

04 120 分

間隔をあけた復習と次のステップ計画

独立習得チェック — 評価対象の作業中に AI の支援は受けられません。支援を受けた場合は誠実に申告することが必須ですが、支援を受けた作業はあくまで復習扱いです。習得を主張する前に、新しい無支援チェックを完了してください。

前提条件

day-03-act-03 の修了と、自分が記録したデイ 01–03 の証拠。

学習目標

3日間のメソッドを想起し、証拠を習得基準と比較して、抜けた概念ごとに復習を予定する。

手順

実際のデイ 01–03 の証拠に紐づいた間隔復習計画を立てます。汎用のルーブリックの繰り返しではありません。各概念について、証拠の状態(検証済み/古い/欠落)、実行する次の無支援チェック、具体的な日付、そのチェックが失敗した場合の復習アクションを記録します。対処可能な証拠ギャップ(例:Windows コマンド未実行、実演エージェント証拠保留中)を明示的に列挙してください。宣言したデイ 01–03 の範囲に最新の証拠が揃っている場合は、実際の証拠を引用し日付入り再チェックを添えた「宣言した範囲では発見なし」を正当化して記録します。ギャップを捏造したり未実行の主張を隠したりしてはいけません。日付入りの無支援の次回チェックを1件確約してください。

演習と予測記録

少なくとも4つのデイ 01–03 の概念をカバーする復習計画を作成してください。各行に 概念|証拠の状態|次の無支援チェック|日付|抜けた場合の復習アクション を記録します。次に、自分の記録にある対処可能な証拠ギャップ(信じてはいるが検証していないこと)をすべて挙げます。宣言した範囲内に存在しない場合は、実際の現在の証拠と日付入りの新しい無支援再チェックを引用した明示的な「宣言した範囲では発見なし」でのみ認められます。既存のギャップは必ず開示し、隠してはいけません。計画の最後に予定した新規チェックで締めてください。その日に、新しいミューテーション/同一性スニペットを無支援で予測して検証します。

独立習得基準

計画に少なくとも4つのデイ 01–03 の概念が含まれ、それぞれに証拠の状態・実行可能な無支援チェック・具体的な日付・復習アクションが記名されており、対処可能な証拠ギャップが少なくとも1件挙げられる、または宣言した範囲内の実際の現在の証拠を引用した正当化された「発見なし」の明示があること。日付入りの無支援の次回チェックが確約されている場合に合格。支援は復習扱いのみであり、習得を主張する前に新しい無支援チェックが必要です。

公式ソースリソースと権利証跡

linking Journal publisher copyright (all rights reserved) - lawful external linking only

Test-Enhanced Learning: Taking Memory Tests Improves Long-Term Retention

著者・提供機関: Henry L. Roediger III, Jeffrey D. Karpicke | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Psychological Science 17(3): 249-255, Experiments 1-2

検証バージョンと日付: Psychological Science, 2006 (Verified: 2026-10-30)

選定理由:

Foundational experimental evidence that retrieval practice (testing) outperforms repeated study for long-term retention; grounds the Day 88 AI-free retrieval checks in peer-reviewed learning science rather than folk advice.

ソース前提知識:

Basic understanding of study sessions, retention intervals, and experimental design vocabulary.

安全フォールバック(オフライン回復性):

The curriculum restates the experimental design and effect sizes in original prose; every sealed task runs without the paper.

比較対象候補リソースと選定評価 (2)

Strong meta-analytic coverage of spacing effects but addresses scheduling rather than the retrieval effect itself; retained as support for the Day 90 spaced-review schedule.

Equally foundational follow-up demonstrating repeated retrieval vs repeated study; the 2006 paper is cited as the standard first controlled demonstration.

linking Journal publisher copyright (all rights reserved) - lawful external linking only

Improving Students' Learning With Effective Learning Techniques: Promising Directions From Cognitive and Educational Psychology

著者・提供機関: John Dunlosky, Katherine A. Rawson, Elizabeth J. Marsh, Mitchell J. Nathan, Daniel T. Willingham | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Psychological Science in the Public Interest 14(1): 4-58; practice testing and distributed practice sections

検証バージョンと日付: Psychological Science in the Public Interest, 2013 (Verified: 2026-10-30)

選定理由:

Detailed comparative review rating practice testing and distributed practice as high-utility techniques while rating highlighting and rereading low-utility; anchors the retrieval, correction, and spaced-review design of Days 88-90.

ソース前提知識:

None beyond general academic reading.

安全フォールバック(オフライン回復性):

Curriculum restates the utility ratings and application conditions in original prose; every task remains runnable offline.

比較対象候補リソースと選定評価 (2)
Pashler et al. Learning Styles: Concepts and Evidence ↗ compared_alternative [Publisher copyright (originally Wiley; now SAGE Publications)]

Important negative result on learning-styles matching but narrower scope; Dunlosky et al. rates a broader set of techniques directly usable for this curriculum.

Brown, Roediger & McDaniel: Make It Stick: The Science of Successful Learning ↗ compared_alternative [Publisher copyright (Harvard University Press)]

Strong trade-book synthesis of the same evidence base; the peer-reviewed review is preferred for citation precision and technique-by-technique utility ratings.