03 / 90

Day 03: Recovery drill: diagnose a failed environment

Recovery drill: diagnose a failed environment。Each activity keeps prediction, observation, review, and recovery evidence.

Self-Directed Learning & Python 480 active minutes (8 hours focused study)
01 120 min

Recovery drill: diagnose a failed environment

Independent Mastery Check — no AI assistance during assessed work. Disclosing any assistance honestly is required, but assisted work is remediation only: complete a fresh unaided check before claiming mastery.

Prerequisites

Day 02 activities. Bash is required for the assessed path; the verified execution scope is Linux Bash. A working `python3` is required; no installs and no machine-wide changes.

Learning Objective

Diagnose a deliberately broken virtual-environment or path assumption using prediction, minimal reproduction, and recovery notes.

Instructions

This drill ships an intentionally broken but harmless fixture inside a disposable env-drill directory. Predict the symptom before running, reproduce it, gather diagnostic evidence, apply the smallest justified correction, and recheck. Stay inside the fixture directory; change nothing machine-wide (no installs, no edits outside env-drill, no persistent environment changes — the fix below is scoped to a single command invocation). The blocks run in contained fail-stop subshells: setup validates a fresh private mktemp root and aborts before any write on failure, and it also aborts if a non-executing importlib.util.find_spec check finds ambient Python configuration already resolving helper (the intended failure needs that assumption; the probe does not import or run the module). Paste the printed export SBX_ROOT= line before the later blocks; record your shell's original PYTHONPATH setness and value - unset, empty, and nonempty originals are all valid evidence. The final block prints a literal rm -r -- <private-root> cleanup line for the exact root created. Run these blocks under Bash - the printed export/rm -r -- lines use Bash %q quoting and Linux Bash is the executed scope; zsh/dash/Windows are unexecuted.

Practice & Prediction Log

Build the broken fixture and reproduce the failure (paste the whole block; it aborts before writing if setup fails or if a non-executing check finds helper already resolvable):

(
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"
)

Predict the error before running. Paste the printed export SBX_ROOT= line, then gather evidence:

(
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
)

Apply the smallest justified correction for this invocation only and recheck, comparing PYTHONPATH against the recorded original — the block prints an explicit set/unset marker plus the value, so unset, empty, and nonempty originals are all distinguishable unchanged evidence):

(
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"
)

Record symptom, evidence, the fix, why it is minimal, and the recheck result.

Independent Mastery Criterion

Pass when, unaided: (a) the `ModuleNotFoundError` symptom was predicted before running; (b) the diagnostic evidence is recorded (the resolved `sys.path` listing lacking `tools/` and the `ls tools` result showing the file exists); (c) the applied fix is scoped to one invocation with a written justification of why it is minimal; (d) the successful recheck and the no-persistence check are recorded - `PYTHONPATH` after the scoped fix equals the recorded original (unset, empty, or unchanged nonempty). Assistance is remediation only and requires a fresh unaided check before mastery is claimed.

Authoritative Source Resources & Provenance

linking PSF License Version 2

The Python Tutorial: Virtual Environments and Packages

Author: Python Software Foundation | Original Source Link ↗

Relevant Section / Range: Section 12 (creating venvs, pip installs, requirements files)

Verified Version & Date: Python 3.12 (Verified: 2026-10-30)

Selection Rationale:

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

Source Prerequisites:

Basic Python syntax from Study Days 01-09

Safe Fallback (Offline Resilience):

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

Compared Candidate Sources & Selection Analysis (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

Author: Python Software Foundation | Original Source Link ↗

Relevant Section / Range: Sections 8.3-8.6 (handling exceptions, else, finally, cleanup actions)

Verified Version & Date: Python 3.12 (Verified: 2026-10-30)

Selection Rationale:

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

Source Prerequisites:

Basic Python syntax from Study Days 01-09

Safe Fallback (Offline Resilience):

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

Compared Candidate Sources & Selection Analysis (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 min

Agent-assisted engineering review and correction

Agent-Assisted Engineering Check — declare the selected track, permissions, and review boundary; agent output is not independent evidence. If no authorized tool is available, mark the live portion blocked/unexecuted: the pre-authored bad patch below is an offline illustration, not an observed provider output.

Prerequisites

day-03-act-01 plus the Agent Tool Track selection.

Learning Objective

Review an agent-produced change, run the check, identify a failure, and require a correction rather than accepting output blindly.

Instructions

Inside a new agent-review-sandbox, create calc.py containing def add(a, b): return a + b and the independent check check_clamp.py below — your own check, independent of the agent's claims. Then ask your selected agent for exactly this change: "In agent-review-sandbox/calc.py, add a function clamp(x, lo, hi) that returns x bounded to [lo, hi] and raises ValueError when lo > hi. Do not modify add or any other file." Require approval before writes; nothing outside the sandbox. Declared permissions are a contract, not an OS sandbox — verify the scope yourself. Budget: at most 3 agent turns or retries; stop on the check passing, budget exhausted, or any out-of-scope action. If the check passes on the first run, that is valid evidence - do not invent a defect; record the passing output and complete the substantive review instead. The labelled drill patch may then be used separately to practise the correction loop, marked drill evidence. Run your check against whatever was produced. If no authorized tool exists, use the labelled pre-authored patch in the reference solution to practise the loop — it is illustrative, not live evidence.

Practice & Prediction Log

Independent behavior check (write it yourself, save as 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')

Run python3 check_clamp.py against the produced code. If it fails, write precise feedback (which case, expected vs actual, suspected cause), request the correction, capture the diff (git diff or diff -u against a saved copy), and rerun the check. Record: failure output, your feedback, the diff, and the passing recheck. If it passes first try, record the passing output and a substantive evidence review (each assert traced, the lo > hi ValueError path verified, add and other files untouched); you may still practise the feedback loop on the labelled drill patch, recorded as drill evidence, never as agent output.

Independent Mastery Criterion

Pass when: (a) the learner-authored `check_clamp.py` exists and was run against the produced code; (b) EITHER a real failure path is recorded - failure output, feedback naming the failing case plus expected vs actual plus suspected cause, correction diff, and passing recheck - OR a correct first pass is recorded: the passing output plus a substantive evidence review tracing each check, the `lo > hi` path, and scope compliance. A valid result is never altered to invent an agent defect; the labelled drill patch is optional practice evidence marked as such. If no authorized tool exists, the live portion is marked blocked/unexecuted and the loop is demonstrated on the labelled illustration — never presented as live agent output.

Authoritative Source Resources & Provenance

linking Open Access / CC BY 4.0

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

Author: John Yang, Carlos E. Jimenez, Alexander Wettig, Kilian Lieret, Shunyu Yao, Karthik Narasimhan, Ofir Press | Original Source Link ↗

Relevant Section / Range: Section 2 The Agent-Computer Interface and Section 3 SWE-agent: Designing an ACI for Software Engineering

Verified Version & Date: NeurIPS 2024 / arXiv:2405.15793v2 (Verified: 2026-10-30)

Selection Rationale:

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.

Source Prerequisites:

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

Safe Fallback (Offline Resilience):

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

Compared Candidate Sources & Selection Analysis (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

Author: Noah Shinn, Federico Cassano, Ashwin Gopinath, Karthik Narasimhan, Shunyu Yao | Original Source Link ↗

Relevant Section / Range: Section 2 & 3 (Reflexion Architecture and Memory Buffer)

Verified Version & Date: NeurIPS 2023 / arXiv:2303.11366v4 (Verified: 2026-10-30)

Selection Rationale:

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

Source Prerequisites:

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

Safe Fallback (Offline Resilience):

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

Compared Candidate Sources & Selection Analysis (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 min

Independent mastery: filesystem artifact check

Independent Mastery Check — no AI assistance during assessed work. Disclosing any assistance honestly is required, but assisted work is remediation only: complete a fresh unaided check before claiming mastery.

Prerequisites

day-03-act-02. Bash is required for the assessed path; the verified execution scope is Linux Bash.

Learning Objective

Demonstrate independent terminal/filesystem mastery with a fresh task and an inspectable artifact.

Instructions

A fresh transfer task — not the Day 02 sequence. Predict each check before running it and record observed outputs. Everything happens inside a new disposable report-sandbox; touch nothing outside it. The block runs inside a contained fail-stop subshell: a fresh private mktemp root is validated first, and a failed mkdir/cd aborts before any write - it can never write into your current directory. The block ends by printing a literal rm -r -- <private-root> cleanup command (Bash %q-quoted) that names exactly the root it created; run it only if you want that directory removed. Run the block under Bash - Linux Bash is the executed scope; zsh/dash/Windows are unexecuted.

Practice & Prediction Log

Run the whole block below in a fresh Bash shell (as one block), writing predictions before each wc, diff, and find. A failed setup aborts the subshell and writes nothing into your current directory. The block ends by printing a literal rm -r -- <private-root> cleanup command you may run when you want that directory removed:

(
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"
)

Artifact checks to satisfy: the backup is byte-identical to the original; data/readme.txt no longer exists after the move; the final find output lists exactly ./archive/notes.txt, ./archive/sales-q1.bak, and ./data/sales-q1.csv.

Independent Mastery Criterion

Pass when, unaided: (a) predictions precede each `wc`/`diff`/`find` and observed outputs are recorded; (b) all three artifact checks hold — identical `diff` result, `readme.txt` absent from `data/`, and the exact three-file `find` listing; (c) work stayed inside `report-sandbox`. Assistance is remediation only and requires a fresh unaided check before mastery is claimed.

Authoritative Source Resources & Provenance

linking PSF License Version 2

Python Standard Library: pathlib

Author: Python Software Foundation | Original Source Link ↗

Relevant Section / Range: Path.exists, Path.cwd, and anchoring paths to __file__

Verified Version & Date: Python 3.12 (Verified: 2026-10-30)

Selection Rationale:

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

Source Prerequisites:

Basic Python syntax from Study Days 01-09

Safe Fallback (Offline Resilience):

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

Compared Candidate Sources & Selection Analysis (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

Author: Python Software Foundation | Original Source Link ↗

Relevant Section / Range: TemporaryDirectory for disposable on-disk fixtures

Verified Version & Date: Python 3.12 (Verified: 2026-10-30)

Selection Rationale:

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

Source Prerequisites:

Basic Python syntax from Study Days 01-09

Safe Fallback (Offline Resilience):

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

Compared Candidate Sources & Selection Analysis (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 min

Spaced review and next-step plan

Independent Mastery Check — no AI assistance during assessed work. Disclosing any assistance honestly is required, but assisted work is remediation only: complete a fresh unaided check before claiming mastery.

Prerequisites

day-03-act-03 plus your own recorded Days 01–03 evidence.

Learning Objective

Retrieve the three-day method, compare evidence with the mastery criteria, and schedule recovery for every missed concept.

Instructions

Build a spaced-retrieval plan tied to your actual Days 01–03 evidence — not another generic rubric. For each concept, record its evidence status (verified / stale / missing), the next unaided check you will perform, a concrete date, and the recovery action if that check fails. List your actionable evidence gaps explicitly (e.g. Windows commands never executed, live agent evidence pending) - or, if your declared Days 01-03 scope has complete current evidence, record a justified "none found within this declared scope" citing the actual evidence plus a dated recheck. Never invent a gap or hide an unexecuted claim. Commit to one dated, unaided next check.

Practice & Prediction Log

Produce a recovery plan covering at least four Days 01–03 concepts. For each row record: concept | evidence status | next unaided check | date | recovery action if missed. Then list every actionable evidence gap in your records (things you believe but have not verified); if none exist inside your declared scope, an explicit "none found within this declared scope" is acceptable only when it cites the actual current evidence and a dated fresh unaided recheck - existing gaps must still be disclosed, never hidden. Close the plan with a scheduled fresh check: a date on which you will predict a new mutation/identity snippet and verify it unaided.

Independent Mastery Criterion

Pass when the plan contains at least four Days 01–03 concepts, each with a named evidence status, an executable unaided check, a concrete date, and a recovery action; at least one actionable evidence gap is listed OR an explicit justified none-found statement cites the actual current evidence within the declared scope; and a dated unaided next check is committed. Assistance is remediation only and requires a fresh unaided check before mastery is claimed.

Authoritative Source Resources & Provenance

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

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

Author: Henry L. Roediger III, Jeffrey D. Karpicke | Original Source Link ↗

Relevant Section / Range: Psychological Science 17(3): 249-255, Experiments 1-2

Verified Version & Date: Psychological Science, 2006 (Verified: 2026-10-30)

Selection Rationale:

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.

Source Prerequisites:

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

Safe Fallback (Offline Resilience):

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

Compared Candidate Sources & Selection Analysis (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

Author: John Dunlosky, Katherine A. Rawson, Elizabeth J. Marsh, Mitchell J. Nathan, Daniel T. Willingham | Original Source Link ↗

Relevant Section / Range: Psychological Science in the Public Interest 14(1): 4-58; practice testing and distributed practice sections

Verified Version & Date: Psychological Science in the Public Interest, 2013 (Verified: 2026-10-30)

Selection Rationale:

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.

Source Prerequisites:

None beyond general academic reading.

Safe Fallback (Offline Resilience):

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

Compared Candidate Sources & Selection Analysis (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.