Files
2026-07-13 12:09:03 +08:00

91 lines
3.4 KiB
JSON

{
"lesson": "35-initialization-scripts",
"title": "Initialization Scripts for Agents",
"questions": [
{
"stage": "pre",
"question": "What does an init script eliminate?",
"options": [
"Latency from inference",
"The per-session setup tax: probing runtime, listing the repo, retrying the same checks each new session",
"Provider rate limits",
"Authn tokens"
],
"correct": 1,
"explanation": "The script pays the tax once and writes the answers into init_report.json the agent reads."
},
{
"stage": "pre",
"question": "What is the init script's failure-mode contract?",
"options": [
"Fail soft and continue",
"Fail loud, fail fast, fail in one place; refuse to start when the workbench is broken",
"Always succeed",
"Retry forever"
],
"correct": 1,
"explanation": "The whole point is to refuse to start when the workbench is broken; silent fallback defeats the purpose."
},
{
"stage": "check",
"question": "Which is NOT one of the probes the lesson lists?",
"options": [
"Runtime versions",
"Dependency availability",
"Test command resolvability",
"Token-by-token sampling temperature"
],
"correct": 3,
"explanation": "Probes include runtime versions, deps, test command, paths, env vars, state freshness, last-known-good commit."
},
{
"stage": "check",
"question": "Why does the lesson say init must be idempotent?",
"options": [
"It satisfies SOC 2",
"Running it twice should be a no-op except for a fresh timestamp, so it can be wired into CI, hooks, or a pre-task slash command",
"Idempotence saves money",
"It is required by JSON Schema"
],
"correct": 1,
"explanation": "Idempotence makes init safe to call from many entry points (hooks, CI, slash command)."
},
{
"stage": "check",
"question": "What is last-known-good commit anchoring?",
"options": [
"The most recent commit by the team lead",
"Probe the current commit against an LKG file; refuse to start if the diff exceeds a budget without human ratification",
"The earliest commit in the repo",
"The merge base of HEAD and main"
],
"correct": 1,
"explanation": "Cloudflare's AI Code Review scopes reviewers against the LKG to prevent drift compounding across sessions."
},
{
"stage": "post",
"question": "What does the lock file with TTL pattern do?",
"options": [
"Locks the repo from edits",
"Writes prereqs.lock after a successful probe pass; subsequent runs trust the lock for 24h and skip expensive probes if the manifest hash matches",
"Blocks all writes for 24 hours",
"Disables CI"
],
"correct": 1,
"explanation": "Same shape as Docker layer caches: idempotent probe + content hash = skip."
},
{
"stage": "post",
"question": "What should NEVER appear in the init hot path?",
"options": [
"Local filesystem reads",
"Network calls, LLM calls, external license checks; probes are deterministic plumbing under three seconds",
"Reading env vars",
"Reading the lockfile"
],
"correct": 1,
"explanation": "A probe that calls an LLM is a workflow, not a probe; keep init deterministic."
}
]
}