Harness engineering beginner tutorial, from 0 to 1
TypeScript agentagenticagentic-aiaiai-agentai-agentsdshdsh-pluginharnessharness-engineeringharness-frameworkllm
Refine lecture handouts and project briefs
sanbuphy28f9413d691f
diff --git a/lectures/lecture-01-why-capable-agents-still-fail/README.md b/lectures/lecture-01-why-capable-agents-still-fail/README.mdindex e435321..4ac4dce 100644--- a/lectures/lecture-01-why-capable-agents-still-fail/README.md+++ b/lectures/lecture-01-why-capable-agents-still-fail/README.md@@ -1,27 +1,76 @@# Lecture 01. Why Capable Agents Still Fail-## Guiding Question+## Question-Why do capable models still fail on real software tasks?+Why do strong foundation models still fail on practical software tasks?-## Why This Matters+## Why It Matters-Harness engineering begins when model capability is no longer the main-bottleneck. Strong agents still fail when their environment is underspecified,-their goals are vague, and their feedback loops are weak.+If failures are misdiagnosed as model limitations, teams often spend effort on+model upgrades when the larger issue is execution design. OpenAI and Anthropic+both emphasize that agent reliability depends heavily on the harness: task+definition, tool access, state handling, and verification flow.-## Core Ideas+## Core Concepts-- Reliability is a systems property, not just a model property.-- Many failures that look like model weakness are actually harness weakness.-- When an agent struggles, the useful question is often: what was missing from- the environment?+- Reliability is a system-level outcome, not a model-only metric.+- Many observed failures are harness-induced, even when the model is capable.+- Failures should be treated as diagnostic signals for missing environment+ structure.+- Iterative improvement requires a repeatable loop: run, inspect, patch, rerun.-## Primary Readings+## Detailed Explanation-- OpenAI: Harness engineering: leveraging Codex in an agent-first world-- Anthropic: Effective harnesses for long-running agents+In controlled benchmarks, a model may appear highly capable. In real+repositories, the same model often fails because it operates under uncertainty:+unclear task boundaries, incomplete setup instructions, weak observability, or+no enforced definition of done.-## Code+OpenAI frames this as harness engineering: external scaffolding that allows the+model to act coherently on real work. Anthropic similarly shows that+long-running agent performance depends on explicit recovery paths, stable state,+and reliable feedback loops.-See [`code/`](./code/README.md) for small examples and failure sketches.+Typical failure pattern:++1. The agent starts with incomplete context.+2. It makes locally reasonable changes.+3. It cannot verify global correctness.+4. It overestimates completion and exits early.++This pattern does not imply weak reasoning. It indicates insufficient structure+around reasoning. Therefore, the first response to failure should be+instrumentation and diagnosis, followed by targeted harness changes.++## Examples and Artifacts++- Failure signals to capture:+- Excessive exploration before the first concrete change.+- Partial implementation without durable progress notes.+- "Task complete" claims without test evidence.+- New sessions repeating prior discovery work.+- Practice artifacts:+- Task brief with explicit scope boundaries.+- Startup and health-check command list.+- Required verification command set.+- Session handoff notes in the repository.+- Code examples for this lecture: [`code/README.md`](./code/README.md)++## Readings++- Primary:+- OpenAI: *Harness engineering: leveraging Codex in an agent-first world*+- Anthropic: *Effective harnesses for long-running agents*+- Secondary:+- LangChain: *The Anatomy of an Agent Harness*+- HumanLayer: *Skill Issue: Harness Engineering for Coding Agents*++## Exercises++1. Run the same task in two environments: one with minimal repo guidance and+ one with explicit startup plus verification instructions. Record differences+ in time-to-first-correct-step.+2. Provide a task without a verification plan. Observe where and why completion+ is asserted prematurely.+3. Add one harness improvement (for example, a required test command), rerun the+ task, and compare failure frequency.diff --git a/lectures/lecture-01-why-capable-agents-still-fail/code/failure-signals-checklist.md b/lectures/lecture-01-why-capable-agents-still-fail/code/failure-signals-checklist.mdnew file mode 100644index 0000000..fface47--- /dev/null+++ b/lectures/lecture-01-why-capable-agents-still-fail/code/failure-signals-checklist.md@@ -0,0 +1,10 @@+# Failure Signals Checklist++Use this checklist when reviewing a weak harness run.++- Did the agent ask, or infer incorrectly, how to start the app?+- Did it create directories or abstractions that do not match the intended+ product?+- Did it stop after making a visible UI shell without a complete workflow?+- Did it leave notes or artifacts that help a future run continue?+- Could a fresh session understand what happened in under five minutes?diff --git a/lectures/lecture-01-why-capable-agents-still-fail/code/underspecified-task.md b/lectures/lecture-01-why-capable-agents-still-fail/code/underspecified-task.mdnew file mode 100644index 0000000..52fac65--- /dev/null+++ b/lectures/lecture-01-why-capable-agents-still-fail/code/underspecified-task.md@@ -0,0 +1,18 @@+# Underspecified Task Example++Build a desktop knowledge base app with AI question answering.++Constraints:++- None specified+- No startup command given+- No folder structure guidance+- No data model defined+- No explicit completion criteria++Typical outcomes from this kind of prompt:++- the agent invents a structure ad hoc+- the app may compile but not start consistently+- the UI may appear before there is any usable ingest/query path+- the agent often stops after cosmetic successdiff --git a/lectures/lecture-02-what-a-harness-actually-is/README.md b/lectures/lecture-02-what-a-harness-actually-is/README.mdindex b3dee6a..0efc9c6 100644--- a/lectures/lecture-02-what-a-harness-actually-is/README.md+++ b/lectures/lecture-02-what-a-harness-actually-is/README.md@@ -1,29 +1,74 @@# Lecture 02. What a Harness Actually Is-## Guiding Question+## Question-What counts as a harness, and what does not?+What is included in an agent harness, and what is outside that boundary?-## Why This Matters+## Why It Matters-If the definition stays vague, every configuration detail feels optional. The-course needs a precise boundary: the model contains the intelligence, and the-harness is everything built around it to make that intelligence useful.+Without a precise definition, teams underinvest in critical infrastructure and+overfocus on prompt edits. OpenAI and Anthropic both treat the harness as a+first-class engineering surface that determines whether model capability can be+used reliably.-## Core Ideas+## Core Concepts-- Agent = Model + Harness.-- A harness includes code, configuration, execution logic, and control flow that- are outside the model.-- Examples include instructions, tools, filesystems, sandboxes, hooks,- verification loops, and orchestration.-- Prompts are part of the harness, but the harness is much larger than prompts.+- Working definition: Agent system = Model + Harness.+- The model contributes reasoning; the harness contributes execution conditions.+- Prompts are one harness component, not the whole harness.+- Any component that changes agent perception, action, memory, or verification+ belongs to harness design.-## Primary Readings+## Detailed Explanation-- LangChain: The Anatomy of an Agent Harness-- OpenAI: Harness engineering: leveraging Codex in an agent-first world+For this course, use an operational boundary:-## Code+**If a component is not model weights, it is part of the harness.**-See [`code/`](./code/README.md) for small harness boundary examples.+This boundary is useful because it avoids false distinctions such as "real+engineering" versus "prompt work." From the agent's perspective, instructions,+tooling, runtime limits, repository layout, and validation hooks all influence+outcomes.++A practical harness usually includes:++- Instructions: system messages and repo-local directives.+- Capabilities: shell, APIs, MCP tools, browser, and file operations.+- Environment: sandbox, dependency state, and runtime configuration.+- State: plans, progress logs, feature artifacts, and commit history.+- Control and feedback: tests, linters, evaluators, retry logic, and logs.++The same model can perform very differently across repositories because these+surfaces vary. Performance changes are often harness effects, not model changes.++## Examples and Artifacts++- Boundary test:+- Remove a component and ask whether agent access, action, state continuity, or+ error recovery changed.+- If behavior changes materially, the removed component is harness-critical.+- Lecture examples: [`code/README.md`](./code/README.md)+- Typical artifacts to audit:+- `AGENTS.md` or equivalent instruction entrypoint.+- Setup and verification scripts.+- Persistent work-state files.+- Post-run logs or evaluation summaries.++## Readings++- Primary:+- OpenAI: *Harness engineering: leveraging Codex in an agent-first world*+- Anthropic: *Effective harnesses for long-running agents*+- Secondary:+- LangChain: *The Anatomy of an Agent Harness*+- Thoughtworks: *Harness Engineering*+- HumanLayer: *Skill Issue: Harness Engineering for Coding Agents*++## Exercises++1. Compare one model across two repositories with different instruction and tool+ surfaces. List which behavior differences are attributable to harness changes.+2. Disable one harness layer (for example, validation hooks) and classify the+ new failures that appear.+3. Create a one-page harness inventory for a current project and mark missing+ or weak components.diff --git a/lectures/lecture-02-what-a-harness-actually-is/code/harness-components.md b/lectures/lecture-02-what-a-harness-actually-is/code/harness-components.mdnew file mode 100644index 0000000..8595b9b--- /dev/null+++ b/lectures/lecture-02-what-a-harness-actually-is/code/harness-components.md@@ -0,0 +1,21 @@+# Harness Components Example++For a coding agent working in a local repository:++- Model:+ the LLM itself++- Harness:+ - system prompt+ - AGENTS.md+ - bash tool+ - file read/write tools+ - git access+ - local filesystem+ - startup scripts+ - test commands+ - stop hooks+ - lint checks+ - evaluator loop++If you change any of the above harness pieces, you change the effective agent.diff --git a/lectures/lecture-02-what-a-harness-actually-is/code/minimal-harness-loop.ts b/lectures/lecture-02-what-a-harness-actually-is/code/minimal-harness-loop.tsnew file mode 100644index 0000000..e56cddd--- /dev/null+++ b/lectures/lecture-02-what-a-harness-actually-is/code/minimal-harness-loop.ts@@ -0,0 +1,36 @@+type Message = {+ role: "user" | "assistant";+ content: string;+};++type ToolResult = {+ ok: boolean;+ output: string;+};++function runTool(name: string, input: string): ToolResult {+ if (name === "read_file") {+ return { ok: true, output: `contents of ${input}` };+ }++ return { ok: false, output: `unknown tool: ${name}` };+}++export function minimalHarness(messages: Message[]) {+ const nextAction = {+ tool: "read_file",+ input: "README.md"+ };++ const result = runTool(nextAction.tool, nextAction.input);++ return {+ messages: [+ ...messages,+ {+ role: "assistant",+ content: `Tool ${nextAction.tool} returned: ${result.output}`+ }+ ]+ };+}diff --git a/lectures/lecture-03-why-the-repository-must-become-the-system-of-record/README.md b/lectures/lecture-03-why-the-repository-must-become-the-system-of-record/README.mdindex 207b4af..71094c0 100644--- a/lectures/lecture-03-why-the-repository-must-become-the-system-of-record/README.md+++ b/lectures/lecture-03-why-the-repository-must-become-the-system-of-record/README.md@@ -1,26 +1,70 @@# Lecture 03. Why the Repository Must Become the System of Record-## Guiding Question+## Question-Why must knowledge live inside the repository rather than outside it?+Why should essential project knowledge be stored in the repository instead of+external chats, tickets, or memory?-## Why This Matters+## Why It Matters-Agents can only reliably use knowledge they can access while working. If key-decisions live in chat threads, docs apps, or human memory, the harness cannot-count on them.+Agents can only use what they can read during execution. OpenAI emphasizes+repo-local context as a prerequisite for reliable automation, and Anthropic+highlights durable state as necessary for long-running continuity. Knowledge+outside the repository is often inaccessible at run time.-## Core Ideas+## Core Concepts-- Agent-invisible knowledge is operationally nonexistent.-- The repository becomes more than code: it becomes the system of record.-- Specs, plans, references, and operational notes should live close to the work.+- Agent-invisible knowledge is operationally unavailable.+- The repository is both codebase and execution memory surface.+- Durable project state should be discoverable by a fresh agent session.+- "System of record" means structured retrieval, not large volumes of prose.-## Primary Readings+## Detailed Explanation-- OpenAI: Harness engineering: leveraging Codex in an agent-first world-- Thoughtworks: Harness Engineering+Human teams can compensate for missing information through meetings, chat+history, and interpersonal memory. Agents usually cannot. As a result,+repository design must assume limited context windows and no implicit recall.-## Code+A repository that functions as a system of record provides concise, current+artifacts for the questions an agent must answer:-See [`code/`](./code/README.md) for repo knowledge layout examples.+- What is this system and what does it do?+- How is it organized?+- How do I run and verify it?+- What work is in progress?+- What constraints are non-negotiable?++These artifacts should be close to execution paths and maintained with the same+discipline as source code. The goal is not "more documentation"; the goal is+minimal, durable, high-utility context for repeatable work.++## Examples and Artifacts++- Typical repository artifacts:+- Architecture overview with current module boundaries.+- Product and behavior constraints relevant to implementation.+- Startup and verification command references.+- Active plan/progress notes for ongoing tasks.+- Interfaces to external systems and quality gates.+- Validation check:+- Start a new agent session and ask it to explain the system and next tasks+ using repository contents only.+- Lecture examples: [`code/README.md`](./code/README.md)++## Readings++- Primary:+- OpenAI: *Harness engineering: leveraging Codex in an agent-first world*+- Anthropic: *Effective harnesses for long-running agents*+- Secondary:+- Thoughtworks: *Harness Engineering*+- LangChain: *The Anatomy of an Agent Harness*++## Exercises++1. Run a "cold-start audit": remove prior chat context and evaluate whether a+ fresh agent can discover architecture, run commands, and open work items.+2. Convert one external knowledge source (for example, a recurring ticket note)+ into a repo-local artifact and measure reusability in subsequent sessions.+3. Identify one stale repository document and replace it with a smaller,+ command-linked artifact that is easier to keep current.diff --git a/lectures/lecture-03-why-the-repository-must-become-the-system-of-record/code/repo-knowledge-layout.txt b/lectures/lecture-03-why-the-repository-must-become-the-system-of-record/code/repo-knowledge-layout.txtnew file mode 100644index 0000000..45315da--- /dev/null+++ b/lectures/lecture-03-why-the-repository-must-become-the-system-of-record/code/repo-knowledge-layout.txt@@ -0,0 +1,13 @@+AGENTS.md+docs/+ ARCHITECTURE.md+ PRODUCT.md+ RELIABILITY.md+ references/+ electron.md+ sqlite.md+ plans/+ active/+ completed/+src/+scripts/diff --git a/lectures/lecture-03-why-the-repository-must-become-the-system-of-record/code/system-of-record-checklist.md b/lectures/lecture-03-why-the-repository-must-become-the-system-of-record/code/system-of-record-checklist.mdnew file mode 100644index 0000000..e0856c5--- /dev/null+++ b/lectures/lecture-03-why-the-repository-must-become-the-system-of-record/code/system-of-record-checklist.md@@ -0,0 +1,11 @@+# System of Record Checklist++Can a fresh agent discover the following from the repo alone?++- What product is being built?+- What the app should do for users?+- How the codebase is organized?+- How the app starts?+- How health is checked?+- What work is currently in progress?+- What quality standards matter?diff --git a/lectures/lecture-04-why-one-giant-instruction-file-fails/README.md b/lectures/lecture-04-why-one-giant-instruction-file-fails/README.mdindex 2595594..47be325 100644--- a/lectures/lecture-04-why-one-giant-instruction-file-fails/README.md+++ b/lectures/lecture-04-why-one-giant-instruction-file-fails/README.md@@ -1,26 +1,72 @@# Lecture 04. Why One Giant Instruction File Fails-## Guiding Question+## Question-Why does a huge instruction file often make an agent worse rather than better?+Why does a large, all-in-one instruction file often reduce agent performance?-## Why This Matters+## Why It Matters-Big instruction files feel safe because they hold “everything,” but in practice-they consume context, blur priorities, and decay quickly.+Instruction design directly affects context allocation and task focus. OpenAI+and Anthropic both show that long-running agent quality depends on clear+priorities, recoverable state, and accessible references. Oversized instruction+files usually degrade all three.-## Core Ideas+## Core Concepts-- Context is scarce, so giant instruction files crowd out task-relevant signal.-- When everything is important, nothing is prioritized.-- Large files rot quickly and are hard to verify mechanically.-- Better harnesses use a short entrypoint plus progressive disclosure.+- Context windows are limited; low-value global text displaces task-critical+ content.+- Undifferentiated rules create priority ambiguity.+- Large files become stale quickly and are difficult to validate.+- Progressive disclosure outperforms monolithic instruction accumulation.-## Primary Readings+## Detailed Explanation-- OpenAI: Harness engineering: leveraging Codex in an agent-first world-- HumanLayer: Skill Issue: Harness Engineering for Coding Agents+Teams commonly respond to failures by appending more rules to one central file.+This local fix creates a global cost: the entry document becomes a mixed set of+timeless constraints, historical edge cases, and obsolete advice.-## Code+As the file grows, three problems appear:-See [`code/`](./code/README.md) for instruction layout examples.+1. The agent spends early context budget parsing generic guidance.+2. New, relevant instructions are harder to detect.+3. Maintenance quality declines because edits are risky and slow.++A more reliable pattern is to keep the top-level instruction document short and+routing-oriented. It should provide orientation, startup commands, verification+requirements, and hard constraints. Topic detail should live in linked,+maintained documents near the code they describe.++This structure supports both OpenAI-style repo legibility and Anthropic-style+long-horizon continuity by keeping high-priority control information concise and+moving specialized detail to targeted references.++## Examples and Artifacts++- Effective entrypoint file content:+- Repository purpose and scope.+- First-run commands (setup, start, test).+- Globally binding constraints.+- Links to architecture, domain, and workflow documents.+- Anti-pattern indicators:+- Repeated edge-case rules with no source links.+- Contradictory instructions across one large file.+- Large sections with unclear ownership and update cadence.+- Lecture examples: [`code/README.md`](./code/README.md)++## Readings++- Primary:+- OpenAI: *Harness engineering: leveraging Codex in an agent-first world*+- Anthropic: *Effective harnesses for long-running agents*+- Secondary:+- HumanLayer: *Skill Issue: Harness Engineering for Coding Agents*+- Thoughtworks: *Harness Engineering*++## Exercises++1. Split a monolithic instruction file into a short entrypoint plus linked+ topic documents. Compare task completion quality before and after.+2. Mark each instruction in the entrypoint as either "global constraint" or+ "local guidance." Remove items that fit neither class.+3. Run a maintenance audit: for each linked instruction document, assign an+ owner and update trigger to reduce staleness.diff --git a/lectures/lecture-04-why-one-giant-instruction-file-fails/code/AGENTS-short.md b/lectures/lecture-04-why-one-giant-instruction-file-fails/code/AGENTS-short.mdnew file mode 100644index 0000000..cf0ae2d--- /dev/null+++ b/lectures/lecture-04-why-one-giant-instruction-file-fails/code/AGENTS-short.md@@ -0,0 +1,15 @@+# AGENTS.md++## Start Here++- Read `docs/ARCHITECTURE.md`+- Read `docs/PRODUCT.md`+- Use `npm run dev` to start the app+- Use `npm run check` before marking work complete++## Hard Rules++- Do not change Electron main/preload/renderer boundaries without reading+ `docs/ARCHITECTURE.md`+- Do not mark a feature complete without verification+- Leave a clean state for the next sessiondiff --git a/lectures/lecture-04-why-one-giant-instruction-file-fails/code/anti-patterns.md b/lectures/lecture-04-why-one-giant-instruction-file-fails/code/anti-patterns.mdnew file mode 100644index 0000000..2fb84eb--- /dev/null+++ b/lectures/lecture-04-why-one-giant-instruction-file-fails/code/anti-patterns.md@@ -0,0 +1,7 @@+# Instruction File Anti-Patterns++- Putting all repository knowledge into one file+- Repeating the same rule in multiple places+- Encoding obsolete rules that nobody audits+- Writing conditional instructions so specific that they rarely apply+- Embedding long tool manuals into the startup contextdiff --git a/lectures/lecture-05-why-long-running-tasks-lose-continuity/README.md b/lectures/lecture-05-why-long-running-tasks-lose-continuity/README.mdindex 61180b3..406a211 100644--- a/lectures/lecture-05-why-long-running-tasks-lose-continuity/README.md+++ b/lectures/lecture-05-why-long-running-tasks-lose-continuity/README.md@@ -1,25 +1,71 @@# Lecture 05. Why Long-Running Tasks Lose Continuity-## Guiding Question+## Question-Why does agent performance often break when work spans multiple sessions?+Why do agent projects lose continuity across sessions, and what must a harness+persist to prevent that loss?-## Why This Matters+## Why It Matters-Long-running work is not just “more of the same.” Each new session begins with-partial or missing state, which makes continuity itself a harness concern.+Long-running development is a sequence of handoffs. Each handoff can introduce+state loss, ambiguity, and duplicated effort. If continuity is weak, the agent+spends increasing time reconstructing context instead of shipping verified+behavior.-## Core Ideas+## Core Concepts-- Session boundaries create discontinuity.-- A fresh context window does not imply fresh understanding.-- Long-running harnesses need explicit mechanisms for continuity.+- Session boundary: a transition where a new run does not automatically inherit+ complete prior reasoning.+- Working context vs durable state: model context is transient; repository+ artifacts persist.+- Continuity artifact: an external record (file, commit, checklist, status+ entry) that supports reliable handoff.+- Reconstruction cost: time and tokens spent rediscovering project state.+- Drift: divergence between intended state and actual repository/runtime state.-## Primary Readings+## Detailed Explanation++Anthropic’s long-running harness work frames continuity as a systems problem.+Even strong models underperform when each run must infer history from partial+signals. The failure mode is not only "bad generation"; it is missing+infrastructure for handoff.++OpenAI’s harness engineering guidance reinforces the same principle from another+angle: the repository should be the operational system of record, not the chat+transcript. Continuity improves when each run leaves explicit, inspectable+artifacts that answer:++1. What is currently true?+2. What is failing or unfinished?+3. What is the next executable step?++Context summaries can reduce short-term rediscovery, but summaries alone are+not durable state. Long-running reliability requires artifacts that can be+versioned, diffed, and validated across sessions. In practice, this means the+harness must treat handoff quality as a formal requirement, not incidental+documentation.++## Examples and Artifacts++- See [`code/`](./code/README.md) for continuity failure and recovery examples.+- Typical continuity artifacts include a progress log, a feature-status file, a+ clean commit checkpoint, and a short verification record from the latest run.+- A useful handoff artifact states repository status, runtime status, blockers,+ and next action in directly testable terms.++## Readings- Anthropic: Effective harnesses for long-running agents- Anthropic: Harness design for long-running application development+- OpenAI: Harness engineering: leveraging Codex in an agent-first world-## Code+## Exercises-See [`code/`](./code/README.md) for continuity artifact examples.+1. Run the same multi-step task in two sessions: once without continuity+ artifacts, and once with a progress log plus feature-status file. Compare+ reconstruction time.+2. Ask a fresh session to resume work using repository artifacts only (no prior+ conversation context). Record which details were recoverable and which were+ missing.+3. Design a minimal handoff template with exactly four fields. Validate whether+ a new session can safely continue work from that template.diff --git a/lectures/lecture-05-why-long-running-tasks-lose-continuity/code/continuity-checklist.md b/lectures/lecture-05-why-long-running-tasks-lose-continuity/code/continuity-checklist.mdnew file mode 100644index 0000000..6040ea6--- /dev/null+++ b/lectures/lecture-05-why-long-running-tasks-lose-continuity/code/continuity-checklist.md@@ -0,0 +1,6 @@+# Continuity Checklist++- Can a fresh agent identify recent work in under five minutes?+- Is the current stable startup path documented?+- Is unfinished work clearly identified?+- Is the next best task visible without reading old chat logs?diff --git a/lectures/lecture-05-why-long-running-tasks-lose-continuity/code/session-handoff.md b/lectures/lecture-05-why-long-running-tasks-lose-continuity/code/session-handoff.mdnew file mode 100644index 0000000..09030a3--- /dev/null+++ b/lectures/lecture-05-why-long-running-tasks-lose-continuity/code/session-handoff.md@@ -0,0 +1,17 @@+# Session Handoff Example++## Completed++- Added markdown import support+- Added a basic document list in the renderer++## Broken or Unverified++- Import succeeds for `.md` but fails for large `.txt` files+- The app starts, but the detail view has not been wired up++## Next Best Step++- Fix `.txt` import path+- Verify import end-to-end+- Then add the document detail paneldiff --git a/lectures/lecture-06-why-initialization-needs-its-own-phase/README.md b/lectures/lecture-06-why-initialization-needs-its-own-phase/README.mdindex 7879d00..26db732 100644--- a/lectures/lecture-06-why-initialization-needs-its-own-phase/README.md+++ b/lectures/lecture-06-why-initialization-needs-its-own-phase/README.md@@ -1,24 +1,69 @@# Lecture 06. Why Initialization Needs Its Own Phase-## Guiding Question+## Question-Why should the first run of a project do a different job from later runs?+Why should initialization be treated as a separate harness phase instead of+being mixed into ordinary feature implementation?-## Why This Matters+## Why It Matters-Initialization is not ordinary feature work. The first run establishes the-scaffolding that later runs depend on, so it deserves its own phase and logic.+The first run sets the operating conditions for every later run. If startup+rules, verification paths, and state artifacts are unclear at the beginning,+later sessions inherit ambiguity and repeatedly pay for it.-## Core Ideas+## Core Concepts-- Initializer agents reduce ambiguity for later coding agents.-- `init.sh`, initial commits, and progress files act as continuity scaffolds.-- First-run setup is a harness primitive, not a convenience script.+- Initialization phase: a dedicated pass that creates stable project scaffolding+ before feature work begins.+- Bootstrap contract: explicit commands and assumptions for starting, testing,+ and inspecting the project.+- Durable baseline: an initial checkpoint with reproducible behavior and+ documented state.+- Handoff readiness: whether a new session can continue without guessing setup.-## Primary Readings+## Detailed Explanation++Anthropic distinguishes initialization from implementation because the two phases+optimize for different outcomes. Implementation aims to add behavior.+Initialization aims to make future behavior changes reliable.++A strong initializer usually establishes:++1. Startup and verification commands that run consistently.+2. Persistent state artifacts (for example, progress and feature-status files).+3. A first clean checkpoint in version control.+4. A decomposed task surface that supports incremental work.++OpenAI’s harness perspective leads to the same design decision: if the+repository is the system of record, then the first responsibility is to create+clear operational structure inside the repository. Without that structure, each+new run must infer project conventions, which increases error rates and slows+iteration.++Initialization quality should therefore be evaluated by downstream usability:+can a fresh session start, verify, and continue work using explicit artifacts+instead of implicit assumptions?++## Examples and Artifacts++- See [`code/`](./code/README.md) for initializer output and first-run+ scaffolding examples.+- Common initialization artifacts include `init.sh`, a baseline commit, a+ progress artifact, and a structured feature/task surface.+- A practical bootstrap contract includes startup command, test/smoke command,+ artifact locations, and known environmental assumptions.++## Readings- Anthropic: Effective harnesses for long-running agents+- Anthropic: Harness design for long-running application development+- OpenAI: Harness engineering: leveraging Codex in an agent-first world-## Code+## Exercises-See [`code/`](./code/README.md) for initialization artifact examples.+1. Define a bootstrap contract for a new repository using four required fields:+ startup, verification, progress artifact, and next-task source.+2. Compare two project starts: one with generated code only, one with an+ explicit initialization phase. Measure time to first verified feature.+3. Ask a fresh session to continue work using only initializer artifacts. Record+ which missing artifacts caused ambiguity.diff --git a/lectures/lecture-06-why-initialization-needs-its-own-phase/code/init.sh b/lectures/lecture-06-why-initialization-needs-its-own-phase/code/init.shnew file mode 100644index 0000000..2c6e1b0--- /dev/null+++ b/lectures/lecture-06-why-initialization-needs-its-own-phase/code/init.sh@@ -0,0 +1,10 @@+#!/usr/bin/env bash+set -euo pipefail++echo "[init] installing dependencies"+npm install++echo "[init] starting the docs site is optional"+echo "[init] use npm run docs:dev for course docs"++echo "[init] project-specific startup would go here"diff --git a/lectures/lecture-06-why-initialization-needs-its-own-phase/code/initializer-output-checklist.md b/lectures/lecture-06-why-initialization-needs-its-own-phase/code/initializer-output-checklist.mdnew file mode 100644index 0000000..58484c4--- /dev/null+++ b/lectures/lecture-06-why-initialization-needs-its-own-phase/code/initializer-output-checklist.md@@ -0,0 +1,7 @@+# Initializer Output Checklist++- Is there a canonical startup command?+- Is there a canonical verification command?+- Is there a first progress artifact?+- Is there a stable first commit?+- Is there a visible feature surface for later runs?diff --git a/lectures/lecture-07-why-agents-overreach-and-under-finish/README.md b/lectures/lecture-07-why-agents-overreach-and-under-finish/README.mdindex 349be3f..a7d8f5a 100644--- a/lectures/lecture-07-why-agents-overreach-and-under-finish/README.md+++ b/lectures/lecture-07-why-agents-overreach-and-under-finish/README.md@@ -1,25 +1,69 @@-# Lecture 07. Why Scope Must Be Made Explicit+# Lecture 07. Why Agents Overreach and Under-Finish-## Guiding Question+## Question-Why do agents fail when scope is vague, oversized, or implicit?+Why do agent runs often attempt too much scope at once and still fail to finish+end-to-end behavior?-## Why This Matters+## Why It Matters-Agents struggle when they cannot see the real boundary of the task. Harnesses-improve reliability by making scope explicit, enumerable, and incremental.+Overreach causes wide but shallow changes. The repository accumulates partial+implementations, while verified outcomes remain limited. Over time, this+increases maintenance cost and reduces trust in completion claims.-## Core Ideas+## Core Concepts-- Agents tend toward one-shot behavior when scope is not externalized.-- Large, vague tasks increase drift and false completion.-- Feature lists turn intent into a visible work surface.-- Incremental progress is a harness design decision, not a model trait.+- Overreach: attempting multiple loosely defined objectives in one iteration.+- Under-finish: producing partial implementation without verified completion.+- Scope surface: an explicit, enumerable list of work units and their states.+- Work-in-progress limit: a rule that constrains active scope to preserve+ completion quality.+- Completion evidence: objective verification required before status changes.-## Primary Readings+## Detailed Explanation++Anthropic’s long-running observations show a recurring pattern: when prompts are+broad, generator behavior tends toward "start many things" rather than "finish+one thing." This is a harness-level failure mode because the run lacks explicit+control over active scope.++OpenAI’s harness engineering approach suggests a practical correction:+externalize scope and make progress stateful. Instead of a single broad goal,+the harness should define a small next unit of work, expected behavior, and+verification gate. This creates operational back-pressure against premature+completion.++A reliable scope model should let any session answer:++1. Which unit is active right now?+2. What exact behavior marks it complete?+3. What verification has passed?+4. What remains blocked?++When these fields are explicit, the harness can enforce "finish before expand."+This reduces partial drift and increases the share of changes that become+durable, testable behavior.++## Examples and Artifacts++- See [`code/`](./code/README.md) for one-shot failure patterns and incremental+ task-shaping examples.+- Useful artifacts include a structured feature/task list with explicit status+ values and a single active-item policy.+- A run summary should report completed behavior and evidence, not only changed+ files.++## Readings- Anthropic: Effective harnesses for long-running agents+- Anthropic: Harness design for long-running application development+- OpenAI: Harness engineering: leveraging Codex in an agent-first world-## Code+## Exercises-See [`code/`](./code/README.md) for scope-control and feature-surface examples.+1. Rewrite a broad request into five atomic work units, each with one explicit+ completion test.+2. Run one experiment with unlimited active tasks and one with a strict+ single-active-task rule. Compare verified completion count.+3. Inspect a recent diff and classify each change as completed behavior,+ incomplete behavior, or scaffolding. Record evidence for each classification.diff --git a/lectures/lecture-07-why-agents-overreach-and-under-finish/code/next-task-template.md b/lectures/lecture-07-why-agents-overreach-and-under-finish/code/next-task-template.mdnew file mode 100644index 0000000..b97cab0--- /dev/null+++ b/lectures/lecture-07-why-agents-overreach-and-under-finish/code/next-task-template.md@@ -0,0 +1,6 @@+# Next Task Template++- Current highest-priority feature:+- Why this feature is next:+- What counts as passing:+- What must not be changed during this step:diff --git a/lectures/lecture-07-why-agents-overreach-and-under-finish/code/scope-surface-example.md b/lectures/lecture-07-why-agents-overreach-and-under-finish/code/scope-surface-example.mdnew file mode 100644index 0000000..1f52484--- /dev/null+++ b/lectures/lecture-07-why-agents-overreach-and-under-finish/code/scope-surface-example.md@@ -0,0 +1,17 @@+# Scope Surface Example++Task:++- Add indexing to the Electron knowledge app++Bad scope shape:++- “Implement indexing”++Better scope shape:++- Parse imported documents+- Split documents into chunks+- Persist chunk metadata+- Expose indexing status in the UI+- Add a reindex actiondiff --git a/lectures/lecture-08-why-feature-lists-are-harness-primitives/README.md b/lectures/lecture-08-why-feature-lists-are-harness-primitives/README.mdindex d11c4b5..5c344ad 100644--- a/lectures/lecture-08-why-feature-lists-are-harness-primitives/README.md+++ b/lectures/lecture-08-why-feature-lists-are-harness-primitives/README.md@@ -1,26 +1,71 @@-# Lecture 08. Why Verification Must Be Externalized+# Lecture 08. Why Feature Lists Are Harness Primitives-## Guiding Question+## Question-Why can’t agents be trusted to decide for themselves when work is complete?+Why are feature lists a core harness primitive rather than optional planning+documentation?-## Why This Matters+## Why It Matters-Strong completion claims require external verification. Without explicit gates,-agents will often mark work complete based on partial or misleading signals.+Without an explicit feature state model, agents and evaluators cannot reliably+coordinate scope, verification, and completion. Work appears active, but system+state remains ambiguous.-## Core Ideas+## Core Concepts-- “Looks done” is not a useful standard.-- Pass states should be tied to explicit verification.-- End-to-end testing catches failure modes invisible to code-only checks.-- External evaluation and back-pressure improve convergence.+- Feature list: a structured task surface containing units of behavior to build+ and verify.+- State model: explicit feature status values (for example, not started,+ in progress, blocked, passing).+- Verification binding: a required link between each feature and objective+ evidence of correctness.+- Harness primitive: a structure other harness components depend on directly.+- Back-pressure: feedback that prevents unverified work from being marked done.-## Primary Readings+## Detailed Explanation++Anthropic’s harness patterns highlight a key idea: feature lists are not only+for planning; they are control structures for execution. A coding agent needs a+concrete work surface, and the harness needs a place to enforce state+transitions.++OpenAI’s harness framing is compatible with this approach. If repository+artifacts are the system of record, then feature state should also be external+and machine-readable. This allows planners, generators, and evaluators to+operate on the same source of truth instead of exchanging ambiguous summaries.++A feature list becomes a harness primitive when other mechanisms depend on it:++1. Scheduling uses it to select the next unit of work.+2. Verification uses it to gate pass-state transitions.+3. Handoffs use it to recover current status quickly.+4. Reporting uses it to distinguish implemented code from validated behavior.++The practical effect is stronger convergence. Agents can still generate broadly,+but they cannot claim completion without satisfying explicit per-feature+criteria.++## Examples and Artifacts++- See [`code/`](./code/README.md) for pass-state gating and evaluator-loop+ examples.+- A useful feature record includes identifier, behavior statement, verification+ method, status, and evidence reference.+- Strong harnesses permit status changes to `passing` only after a defined test+ or evaluator check succeeds.++## Readings- Anthropic: Effective harnesses for long-running agents- Anthropic: Harness design for long-running application development+- OpenAI: Harness engineering: leveraging Codex in an agent-first world-## Code+## Exercises-See [`code/`](./code/README.md) for pass-state and verification examples.+1. Define a minimal feature-list schema with fields for behavior, verification,+ and status history.+2. Select one feature and specify the exact evidence required for transition+ from `in progress` to `passing`.+3. Compare two runs on the same task: one with free-form progress notes, one+ with a structured feature list and status gates. Measure false-completion+ rate.diff --git a/lectures/lecture-08-why-feature-lists-are-harness-primitives/code/feature_list.json b/lectures/lecture-08-why-feature-lists-are-harness-primitives/code/feature_list.jsonnew file mode 100644index 0000000..8b973e3--- /dev/null+++ b/lectures/lecture-08-why-feature-lists-are-harness-primitives/code/feature_list.json@@ -0,0 +1,15 @@+[+ {+ "id": "qna-001",+ "category": "grounded_qa",+ "description": "User can ask a question about an imported document and receive an answer with visible citations.",+ "verification": [+ "Import a markdown document",+ "Open the Q&A panel",+ "Ask a question about known content",+ "Verify the answer is returned",+ "Verify one or more citations are displayed"+ ],+ "passes": false+ }+]diff --git a/lectures/lecture-08-why-feature-lists-are-harness-primitives/code/pass-gate-policy.md b/lectures/lecture-08-why-feature-lists-are-harness-primitives/code/pass-gate-policy.mdnew file mode 100644index 0000000..c922f64--- /dev/null+++ b/lectures/lecture-08-why-feature-lists-are-harness-primitives/code/pass-gate-policy.md@@ -0,0 +1,8 @@+# Pass Gate Policy++A feature may only move from `passes: false` to `passes: true` when:++- the expected workflow has been exercised+- the evidence of success is recorded+- no blocking error is present in the tested path+- the implementation does not leave the app in a broken or ambiguous statediff --git a/lectures/lecture-09-why-agents-declare-victory-too-early/README.md b/lectures/lecture-09-why-agents-declare-victory-too-early/README.mdindex b68a45f..d994fe9 100644--- a/lectures/lecture-09-why-agents-declare-victory-too-early/README.md+++ b/lectures/lecture-09-why-agents-declare-victory-too-early/README.md@@ -1,27 +1,68 @@-# Lecture 09. Why Runtime Feedback Belongs Inside the Harness+# Lecture 09. Why Agents Declare Victory Too Early-## Guiding Question+## Question-Why do agents need runtime signals and clean state in order to work reliably?+Why do agents report completion before system-level correctness is established?-## Why This Matters+## Why It Matters-If agents can only see code and not the running system, they are forced to-guess. If they leave broken or ambiguous state behind, future sessions become-less reliable.+Premature completion claims create hidden defects, fragile handoffs, and repeated+rework. OpenAI and Anthropic both show that reliable completion depends on+evidence from execution, not only confidence from code edits.-## Core Ideas+## Core Concepts-- Logs, metrics, traces, and runtime state form a feedback channel.-- Runtime visibility changes what the agent can debug and verify.-- Clean state between sessions is part of harness quality.-- Recoverability matters because long-running work compounds errors over time.+- Completion evidence must be observable and reproducible.+- Runtime feedback (logs, traces, process state) is required to validate claims.+- End-of-session cleanliness is part of the definition of done.+- Recovery quality determines whether later sessions can continue productively.-## Primary Readings+## Detailed Explanation-- OpenAI: Harness engineering: leveraging Codex in an agent-first world-- Anthropic: Effective harnesses for long-running agents+OpenAI’s harness guidance emphasizes that repository diffs are not enough to+judge success. Agents need runtime signals that confirm the application started,+critical paths executed, and expected outputs were produced. Without these+signals, agents may treat partial progress as full completion.-## Code+Anthropic’s long-running harness work adds a second requirement: each session+must leave the environment in a clean, restartable state. If a session ends+with ambiguous indexing status, stale artifacts, or undocumented partial work,+the next session inherits uncertainty and spends time re-diagnosing state.-See [`code/`](./code/README.md) for runtime feedback and clean-state examples.+In practice, early victory declarations usually follow this sequence:++1. Local code changes appear plausible.+2. Runtime behavior is under-observed.+3. Verification is skipped or incomplete.+4. Completion is asserted without durable evidence.++A strong harness breaks this sequence by requiring runtime checks and clean-state+exit criteria before completion can be accepted.++## Examples and Artifacts++- `code/indexing.log`: sample runtime record showing startup, import, chunking,+ and completion signals.+- [`code/clean-state-checklist.md`](./code/clean-state-checklist.md): session-exit+ criteria for restartable state.+- [`code/README.md`](./code/README.md): index of lecture artifacts.++## Readings++Primary:+- OpenAI: *Harness engineering: leveraging Codex in an agent-first world*+- Anthropic: *Effective harnesses for long-running agents*++Secondary:+- LangChain: *The Anatomy of an Agent Harness*++## Exercises++1. Define a completion checklist that requires at least three runtime signals.+ Apply it to one feature task and record which previously hidden issues are+ detected.+2. Run a task twice: once without explicit clean-state exit rules and once with+ [`code/clean-state-checklist.md`](./code/clean-state-checklist.md). Compare+ startup time and diagnostic effort in the next session.+3. Review a past "done" claim and identify which missing runtime artifact would+ have made verification stronger.diff --git a/lectures/lecture-09-why-agents-declare-victory-too-early/code/clean-state-checklist.md b/lectures/lecture-09-why-agents-declare-victory-too-early/code/clean-state-checklist.mdnew file mode 100644index 0000000..5a592e3--- /dev/null+++ b/lectures/lecture-09-why-agents-declare-victory-too-early/code/clean-state-checklist.md@@ -0,0 +1,6 @@+# Clean State Checklist++- App starts without manual repair+- Current progress is recorded+- No half-finished import or indexing step remains undocumented+- The next agent can run the standard startup and verification path immediatelydiff --git a/lectures/lecture-09-why-agents-declare-victory-too-early/code/indexing.log b/lectures/lecture-09-why-agents-declare-victory-too-early/code/indexing.lognew file mode 100644index 0000000..8ffe2b0--- /dev/null+++ b/lectures/lecture-09-why-agents-declare-victory-too-early/code/indexing.log@@ -0,0 +1,7 @@+[startup] electron window created+[import] imported 3 documents from /Users/example/Documents/kb+[index] starting chunk pipeline+[index] doc=design-notes.md chunks=18+[index] doc=meeting-summary.txt chunks=9+[index] doc=retrieval-plan.md chunks=13+[index] completed in 2.14sdiff --git a/lectures/lecture-10-why-end-to-end-testing-changes-results/README.md b/lectures/lecture-10-why-end-to-end-testing-changes-results/README.mdindex aa64f36..3552f9f 100644--- a/lectures/lecture-10-why-end-to-end-testing-changes-results/README.md+++ b/lectures/lecture-10-why-end-to-end-testing-changes-results/README.md@@ -1,29 +1,70 @@-# Lecture 10. Why Structure and Taste Must Be Enforced+# Lecture 10. Why End-to-End Testing Changes Results-## Guiding Question+## Question-Why do architecture and engineering taste have to be enforced mechanically in-agent-first systems?+Why do end-to-end tests change agent outcomes even when unit tests pass?-## Why This Matters+## Why It Matters-Agent-generated systems drift quickly if structure and taste exist only as human-preferences. Harnesses preserve quality by turning them into enforceable-constraints.+Unit and lint checks validate local behavior, but many high-cost failures occur+across component boundaries. In agent workflows, end-to-end testing is the main+mechanism for verifying that architecture constraints and user-facing flows hold+together as a system.-## Core Ideas+## Core Concepts-- Architecture rules drift without enforcement.-- Structural tests and lints make boundaries enforceable.-- Taste invariants convert review feedback into reusable harness logic.-- Strict boundaries make future agent work easier and safer.+- End-to-end tests validate cross-layer contracts, not isolated functions.+- Architecture boundaries must be enforced as executable rules.+- Repeated review comments can be promoted into harness checks.+- Remediation-oriented failures improve future agent behavior.-## Primary Readings+## Detailed Explanation-- OpenAI: Harness engineering: leveraging Codex in an agent-first world-- Thoughtworks: Harness Engineering-- HumanLayer: Skill Issue: Harness Engineering for Coding Agents+OpenAI’s harness approach emphasizes mechanical enforcement of important+invariants. In practice, this means a rule should run automatically whenever+changes are proposed, rather than relying on manual detection during review.+End-to-end tests provide this enforcement at system level.-## Code+Anthropic’s long-running harness lessons reinforce the same point: verification+must match the scope of the task. If a task modifies user workflows or process+boundaries, unit-only verification is under-scoped. The harness should require+end-to-end evidence before accepting completion.-See [`code/`](./code/README.md) for structural and taste-enforcement examples.+For Electron-style applications, boundary defects often appear only in integrated+execution:++1. Renderer code reaches directly into filesystem APIs.+2. Preload contracts are bypassed.+3. Service-layer rules are duplicated in UI components.+4. Logging is missing at process boundaries, reducing diagnosability.++End-to-end tests surface these interactions and convert architecture intent into+observable pass/fail criteria.++## Examples and Artifacts++- [`code/architecture-rules.md`](./code/architecture-rules.md): boundary rules+ that should be testable and enforceable.+- [`code/review-feedback-to-rule.md`](./code/review-feedback-to-rule.md): example+ of converting recurring review feedback into automation.+- [`code/README.md`](./code/README.md): index of lecture artifacts.++## Readings++Primary:+- OpenAI: *Harness engineering: leveraging Codex in an agent-first world*+- Anthropic: *Harness design for long-running application development*++Secondary:+- Thoughtworks: *Harness Engineering*++## Exercises++1. Select one user flow that spans renderer, preload, and service layers. Write+ an end-to-end test plan that fails if any boundary rule in+ [`code/architecture-rules.md`](./code/architecture-rules.md) is violated.+2. Identify one repeated code review comment in your project and formalize it as+ a rule, following the pattern in+ [`code/review-feedback-to-rule.md`](./code/review-feedback-to-rule.md).+3. Compare two task runs: one with unit-only verification and one with unit plus+ end-to-end verification. Record differences in escaped defects.diff --git a/lectures/lecture-10-why-end-to-end-testing-changes-results/code/architecture-rules.md b/lectures/lecture-10-why-end-to-end-testing-changes-results/code/architecture-rules.mdnew file mode 100644index 0000000..6a6179b--- /dev/null+++ b/lectures/lecture-10-why-end-to-end-testing-changes-results/code/architecture-rules.md@@ -0,0 +1,6 @@+# Electron Architecture Rules++- Renderer code may not directly access the filesystem.+- Preload is the only bridge between renderer and Electron main.+- Retrieval and indexing logic live in service modules, not UI components.+- Logging should be structured and emitted from service boundaries.diff --git a/lectures/lecture-10-why-end-to-end-testing-changes-results/code/review-feedback-to-rule.md b/lectures/lecture-10-why-end-to-end-testing-changes-results/code/review-feedback-to-rule.mdnew file mode 100644index 0000000..f3cfd40--- /dev/null+++ b/lectures/lecture-10-why-end-to-end-testing-changes-results/code/review-feedback-to-rule.md@@ -0,0 +1,10 @@+# Example: Turning Review Feedback into a Rule++Repeated review comment:++> Do not call filesystem utilities from the renderer. Use the preload bridge.++Promoted harness rule:++- add a lint or import rule preventing `fs` usage in renderer code+- add remediation text explaining the preload boundarydiff --git a/lectures/lecture-11-why-observability-belongs-inside-the-harness/README.md b/lectures/lecture-11-why-observability-belongs-inside-the-harness/README.mdindex ab60c57..6a578f1 100644--- a/lectures/lecture-11-why-observability-belongs-inside-the-harness/README.md+++ b/lectures/lecture-11-why-observability-belongs-inside-the-harness/README.md@@ -1,27 +1,68 @@-# Lecture 11. Why Advanced Harnesses Split Roles+# Lecture 11. Why Observability Belongs Inside the Harness-## Guiding Question+## Question-Why do stronger harnesses separate planning, implementation, and evaluation?+Why should observability be treated as a built-in harness capability rather than+an optional debugging tool?-## Why This Matters+## Why It Matters-As tasks become broader and quality standards rise, a single agent tends to-overload itself. Advanced harnesses split roles so different failure modes can-be handled explicitly.+Without observability, agents cannot reliably distinguish correct execution from+plausible but incorrect output. OpenAI and Anthropic both describe reliability+as an evidence problem: the harness must expose runtime behavior and evaluation+signals in forms that can guide the next decision.-## Core Ideas+## Core Concepts-- Self-evaluation is systematically weak.-- Evaluators provide skepticism and back-pressure.-- Planners help expand and structure scope before implementation begins.-- More complex harnesses are justified only when those roles are load-bearing.+- Runtime observability includes logs, traces, process events, and health checks.+- Workflow observability includes plans, rubrics, and explicit acceptance+ criteria.+- Separate planner, generator, and evaluator roles require shared evidence.+- Observable artifacts enable correction loops across long-running sessions.-## Primary Readings+## Detailed Explanation-- Anthropic: Harness design for long-running application development-- HumanLayer: Skill Issue: Harness Engineering for Coding Agents+OpenAI frames the harness as the mechanism that turns model reasoning into+verifiable engineering work. This requires direct feedback from execution, not+only inspection of generated code. Runtime visibility answers questions such as+whether a flow executed, where it failed, and which boundary caused the failure.-## Code+Anthropic extends this to multi-role workflows. When planner, generator, and+evaluator roles are used, each role needs access to structured artifacts:+contracts, rubrics, and measurable outcomes. If these artifacts are missing,+evaluation becomes subjective and retries become inefficient.-See [`code/`](./code/README.md) for multi-role harness examples.+Observability therefore has two layers:++1. System layer: application runtime signals.+2. Process layer: harness decision artifacts used for evaluation and handoff.++The two layers should be designed together. Runtime signals explain behavior,+while process artifacts explain why a change should be accepted or rejected.++## Examples and Artifacts++- [`code/sprint-contract.md`](./code/sprint-contract.md): explicit goal and+ completion criteria for a bounded upgrade.+- [`code/evaluator-rubric.md`](./code/evaluator-rubric.md): scoring framework for+ grounded quality assessment.+- [`code/README.md`](./code/README.md): index of lecture artifacts.++## Readings++Primary:+- OpenAI: *Harness engineering: leveraging Codex in an agent-first world*+- Anthropic: *Harness design for long-running application development*++Secondary:+- HumanLayer: *Skill Issue: Harness Engineering for Coding Agents*++## Exercises++1. Add one runtime signal and one process artifact to an existing task. Measure+ whether evaluator confidence improves on first pass.+2. Use [`code/evaluator-rubric.md`](./code/evaluator-rubric.md) to score two+ outputs for the same task. Compare where disagreement appears and why.+3. Write a sprint contract using+ [`code/sprint-contract.md`](./code/sprint-contract.md), then run a task and+ record which required signals were missing at review time.diff --git a/lectures/lecture-11-why-observability-belongs-inside-the-harness/code/evaluator-rubric.md b/lectures/lecture-11-why-observability-belongs-inside-the-harness/code/evaluator-rubric.mdnew file mode 100644index 0000000..2c932d8--- /dev/null+++ b/lectures/lecture-11-why-observability-belongs-inside-the-harness/code/evaluator-rubric.md@@ -0,0 +1,8 @@+# Evaluator Rubric Example++Use 1-5 scoring for each dimension:++- Grounding: are answers clearly tied to imported sources?+- Citation quality: are the source references visible and specific?+- Functionality: can the user complete the question-answer flow?+- Product coherence: does the workflow feel integrated?diff --git a/lectures/lecture-11-why-observability-belongs-inside-the-harness/code/sprint-contract.md b/lectures/lecture-11-why-observability-belongs-inside-the-harness/code/sprint-contract.mdnew file mode 100644index 0000000..bae2450--- /dev/null+++ b/lectures/lecture-11-why-observability-belongs-inside-the-harness/code/sprint-contract.md@@ -0,0 +1,12 @@+# Sprint Contract Example++Sprint goal:++- Add visible citations to grounded Q&A results++Done means:++- User asks a question+- App returns an answer+- At least one citation is shown+- Clicking a citation opens the source location in the document viewdiff --git a/lectures/lecture-12-why-every-session-must-leave-a-clean-state/README.md b/lectures/lecture-12-why-every-session-must-leave-a-clean-state/README.mdindex b67cbca..e4f6d40 100644--- a/lectures/lecture-12-why-every-session-must-leave-a-clean-state/README.md+++ b/lectures/lecture-12-why-every-session-must-leave-a-clean-state/README.md@@ -1,28 +1,66 @@-# Lecture 12. Why Harnesses Must Be Measured and Maintained Over Time+# Lecture 12. Why Every Session Must Leave a Clean State-## Guiding Question+## Question-Why do harnesses need benchmarking, cleanup, and operational maintenance?+Why must each agent session end in a clean, restartable state?-## Why This Matters+## Why It Matters-An impressive harness run is not enough. Over time, harnesses drift, models-change, and systems accumulate entropy. Mature harnesses need measurement and-garbage collection.+Long-running development systems degrade when sessions leave ambiguous progress,+stale artifacts, or unresolved structural violations. OpenAI and Anthropic both+indicate that reliability over time depends on operational discipline, not only+successful single runs.-## Core Ideas+## Core Concepts-- Benchmarks should reveal harness differences, not just model differences.-- High-throughput agent systems inevitably accumulate entropy.-- Cleanup, refactoring, and doc gardening are harness responsibilities.-- Operational maturity means the harness keeps working across repeated runs.+- Clean state means the next session can start without manual repair.+- Benchmark slices are needed to detect harness drift over time.+- Cleanup loops reduce entropy in code, docs, and quality signals.+- Maintenance is part of normal harness operation, not emergency work.-## Primary Readings+## Detailed Explanation-- OpenAI: Harness engineering: leveraging Codex in an agent-first world-- Thoughtworks: Harness Engineering-- LangChain: The Anatomy of an Agent Harness+OpenAI’s harness framing highlights repeatability: a workflow should continue to+produce reliable outcomes as tasks and contexts change. This requires measurable+checks beyond one successful demonstration. Benchmark comparisons help isolate+whether a harness change improved completion rate, reduced retries, or caught+more defects before review.-## Code+Anthropic’s long-running agent observations show why clean session exits are+critical. When unfinished work, stale guidance, or weak boundaries accumulate,+later sessions spend effort on state repair instead of forward progress. A clean+exit policy therefore includes explicit recording of progress, removal of stale+artifacts, and confirmation that the standard startup path still works.-See [`code/`](./code/README.md) for benchmark, cleanup, and maintenance examples.+Operationally, clean state and measurement reinforce each other:++1. Cleanup reduces noise.+2. Lower noise improves benchmark signal quality.+3. Clear benchmarks identify where cleanup policy should be strengthened.++## Examples and Artifacts++- [`code/benchmark-comparison-template.md`](./code/benchmark-comparison-template.md):+ template for comparing harness variants.+- [`code/cleanup-loop.md`](./code/cleanup-loop.md): recurring maintenance cycle+ for entropy reduction.+- [`code/README.md`](./code/README.md): index of lecture artifacts.++## Readings++Primary:+- OpenAI: *Harness engineering: leveraging Codex in an agent-first world*+- Anthropic: *Effective harnesses for long-running agents*++Secondary:+- Thoughtworks: *Harness Engineering*++## Exercises++1. Run a fixed task set on two harness variants and complete+ [`code/benchmark-comparison-template.md`](./code/benchmark-comparison-template.md).+ Identify which harness changed both outcome quality and operational cost.+2. Adopt [`code/cleanup-loop.md`](./code/cleanup-loop.md) for one week and track+ which recurring issues disappear versus persist.+3. Draft a clean-exit checklist for your repository. Include startup validation,+ progress recording, and stale-artifact removal criteria.diff --git a/lectures/lecture-12-why-every-session-must-leave-a-clean-state/code/benchmark-comparison-template.md b/lectures/lecture-12-why-every-session-must-leave-a-clean-state/code/benchmark-comparison-template.mdnew file mode 100644index 0000000..45d8a3d--- /dev/null+++ b/lectures/lecture-12-why-every-session-must-leave-a-clean-state/code/benchmark-comparison-template.md@@ -0,0 +1,18 @@+# Benchmark Comparison Template++Harness A:++- completion rate+- average retries+- bugs caught before human review++Harness B:++- completion rate+- average retries+- bugs caught before human review++Interpretation:++- Which harness changed the result?+- Which harness changed the cost of getting the result?diff --git a/lectures/lecture-12-why-every-session-must-leave-a-clean-state/code/cleanup-loop.md b/lectures/lecture-12-why-every-session-must-leave-a-clean-state/code/cleanup-loop.mdnew file mode 100644index 0000000..effd751--- /dev/null+++ b/lectures/lecture-12-why-every-session-must-leave-a-clean-state/code/cleanup-loop.md@@ -0,0 +1,9 @@+# Cleanup Loop Example++Recurring cleanup tasks:++- scan for stale docs+- scan for structural violations+- update quality grades+- open targeted cleanup PRs+- rerun a fixed benchmark slice after cleanupdiff --git a/projects/project-01-baseline-vs-minimal-harness/README.md b/projects/project-01-baseline-vs-minimal-harness/README.mdindex 05640e5..0d0b03a 100644--- a/projects/project-01-baseline-vs-minimal-harness/README.md+++ b/projects/project-01-baseline-vs-minimal-harness/README.md@@ -1,13 +1,67 @@# Project 01. Baseline vs Minimal Harness-Goal:+## Objective-- Build the first version of the Electron knowledge app with Codex or Claude- Code and compare a weak harness against a minimal harness.+Establish a measurable baseline for harness engineering by comparing a weak+prompt-only setup against a minimal but explicit harness while building the+first runnable slice of the Electron knowledge app.-Suggested contents:+## Learning Goals-- `baseline/`-- `stronger/`-- `artifacts/`+- Observe how harness quality changes completion reliability.+- Practice controlling variables across two agent runs.+- Produce evidence that distinguishes "looks complete" from "is runnable."+## Task++Implement the smallest usable shell of the application:++- Electron window launches successfully.+- UI shows a document list region.+- UI shows a question panel region.+- App creates and uses a local data directory.++Use the same task prompt, model, and time budget for both runs.++## Baseline Harness Setup++Run 1 must intentionally use a weak harness:++- Provide only a high-level product prompt.+- Do not provide repo-local agent instructions (`AGENTS.md`).+- Do not provide a startup command.+- Do not provide a completion checklist.++## Improved Harness Setup++Run 2 must use a minimal explicit harness:++- Add a short `AGENTS.md` in the repo root.+- Include one canonical startup command.+- Include a short definition of done for this project.+- Include a note enforcing Electron layer boundaries.++## Procedure++1. Start from one common commit and record the commit hash.+2. Create two branches: `p01-baseline` and `p01-improved`.+3. In each branch, run Codex or Claude Code with the same task prompt.+4. Cap each run to the same budget (time and number of agent turns).+5. For each run, execute the startup command and verify the app launches.+6. Capture terminal output, key diffs, and final agent summary.+7. Do not manually fix code between the run and measurement step.+8. Compare outcomes only after both runs are complete.++## What to Measure++- Task completion status (`fully complete`, `partial`, `failed`).+- Time to first successful launch.+- Number of retries needed before runnable state.+- Missing acceptance criteria at run end.+- Evidence of early-stop behavior (agent declared done before runnable state).++## Deliverables++- Baseline run record: prompt, transcript/log, final diff, launch evidence.+- Improved run record: prompt, transcript/log, final diff, launch evidence.+- One comparison note (1-2 pages) with measured differences and conclusion.diff --git a/projects/project-02-agent-readable-workspace/README.md b/projects/project-02-agent-readable-workspace/README.mdindex 1aef5ac..020356f 100644--- a/projects/project-02-agent-readable-workspace/README.md+++ b/projects/project-02-agent-readable-workspace/README.md@@ -1,12 +1,69 @@# Project 02. Agent-Readable Workspace and Continuity Scaffold-Goal:+## Objective-- Improve the repository structure, instructions, docs, and continuity artifacts- so the agent can continue development more reliably across sessions.+Demonstrate that repository readability and explicit continuity artifacts reduce+context loss when development spans multiple agent sessions.-Suggested contents:+## Learning Goals-- `baseline/`-- `stronger/`-- `artifacts/`+- Design workspace artifacts that survive session resets.+- Measure multi-session handoff quality instead of single-run output quality.+- Build repeatable continuity practices for Codex or Claude Code workflows.++## Task++Extend the app with three concrete capabilities:++- Document import flow.+- Document detail view.+- Basic persistence for imported documents.++Implementation must be completed across at least two separate agent sessions.++## Baseline Harness Setup++Run 1 must use weak continuity support:++- Sparse or generic instructions only.+- No explicit documentation hierarchy.+- No required progress or handoff artifact.+- No startup/bootstrap helper script.++## Improved Harness Setup++Run 2 must include explicit continuity scaffolding:++- Repo-root `AGENTS.md` with startup and working rules.+- Local docs for architecture, startup, and current status.+- A durable handoff file updated at end of each session.+- An `init.sh` (or equivalent) to restore runnable state quickly.++## Procedure++1. Start from one common commit and branch into `p02-baseline` and+ `p02-improved`.+2. For each branch, run Session A with Codex or Claude Code and stop before all+ tasks are complete.+3. End Session A by saving whatever continuity artifacts the harness allows.+4. Start Session B in a fresh agent context and continue from repository state+ only.+5. Use the same feature scope, model, and run budget in both branches.+6. Verify final behavior by running the project startup command and testing the+ three required capabilities.+7. Record where Session B had to rediscover missing context.++## What to Measure++- Session B startup time to first meaningful code edit.+- Number of rediscovery steps (architecture, commands, status).+- Continuity artifact completeness and correctness.+- Ratio of repeated work to new work in Session B.+- Final task completion status after Session B.++## Deliverables++- Baseline multi-session record (Session A + Session B logs/transcripts).+- Improved multi-session record (Session A + Session B logs/transcripts).+- Continuity artifacts produced in each run.+- One comparison note focused on continuity quality and recovery speed.diff --git a/projects/project-03-multi-session-continuity/README.md b/projects/project-03-multi-session-continuity/README.mdindex 0517a7b..c16683c 100644--- a/projects/project-03-multi-session-continuity/README.md+++ b/projects/project-03-multi-session-continuity/README.md@@ -1,12 +1,67 @@# Project 03. Scope Control and Grounded Verification-Goal:+## Objective-- Compare weak and strong harnesses while adding indexing and grounded Q&A with- explicit scope control and stronger verification.+Evaluate whether explicit scope control and verification gates improve delivery+accuracy when implementing indexing and grounded Q&A features.-Suggested contents:+## Learning Goals-- `baseline/`-- `stronger/`-- `artifacts/`+- Use feature-level state tracking to prevent scope drift.+- Enforce "failing -> passing" transitions with evidence.+- Validate grounded answers with citation checks, not confidence claims.++## Task++Implement the following product slice:++- Document chunking.+- Metadata extraction.+- Indexing state display in the UI.+- Minimal grounded Q&A flow with source citations.++At least one feature must be shown moving from failing to passing.++## Baseline Harness Setup++Run 1 must use a weak control model:++- Vague task prompt.+- No explicit feature list or state file.+- No pass-state gating rules.+- Minimal or ad hoc verification.++## Improved Harness Setup++Run 2 must use explicit scope and verification controls:++- `feature_list.json` (or equivalent) with per-feature status.+- One-feature-at-a-time execution policy.+- Status may switch to `pass` only after verification evidence is captured.+- Grounded Q&A checks must verify citation presence and citation relevance.++## Procedure++1. Start from one common commit and branch into `p03-baseline` and+ `p03-improved`.+2. Define the same feature set for both runs before coding begins.+3. Run the baseline harness with Codex or Claude Code and collect outcomes.+4. Run the improved harness with the same model and comparable budget.+5. In the improved run, require status updates after each feature checkpoint.+6. Execute verification steps for indexing and grounded Q&A in both runs.+7. Archive evidence showing at least one feature transition from fail to pass.++## What to Measure++- Scope drift incidents (work outside agreed feature set).+- False completion rate (claimed done but failed checks).+- Percentage of features with explicit verification evidence.+- Grounded Q&A quality (citation presence and relevance).+- Total implementation retries required to reach passing state.++## Deliverables++- Baseline run artifacts (prompt, transcript/log, verification results).+- Improved run artifacts (feature list history, transcript/log, verification).+- Evidence of at least one fail-to-pass feature transition.+- Short comparison note focused on scope discipline and completion accuracy.diff --git a/projects/project-04-incremental-indexing/README.md b/projects/project-04-incremental-indexing/README.mdindex 75e90a5..1f20b41 100644--- a/projects/project-04-incremental-indexing/README.md+++ b/projects/project-04-incremental-indexing/README.md@@ -1,12 +1,65 @@# Project 04. Runtime Feedback and Structural Control-Goal:+## Objective-- Compare weak and strong harnesses while adding runtime visibility and- enforcing Electron structure and taste constraints.+Compare weak versus improved harnesses while introducing runtime observability+and enforcing structural boundaries in an Electron codebase.-Suggested contents:+## Learning Goals-- `baseline/`-- `stronger/`-- `artifacts/`+- Add runtime signals that shorten debugging cycles.+- Encode architecture constraints so the agent cannot silently violate layers.+- Measure fix quality, not just bug closure speed.++## Task++Implement and validate the following:++- Startup logging.+- Import and indexing logs.+- A visible Q&A failure path (user-facing error state).+- Explicit boundaries between `main`, `preload`, `renderer`, and services.++Debug one seeded runtime defect during each run.++## Baseline Harness Setup++Run 1 must use weak runtime and structure controls:++- Weak or missing runtime signals.+- No formal structural checks.+- No encoded architecture rules in repository artifacts.++## Improved Harness Setup++Run 2 must encode observability and boundaries:++- Explicit runtime logs and health signals.+- Clean-state requirement before final handoff.+- Architecture constraints documented in repo instructions.+- Structural checks via lint rules, tests, or guard scripts.++## Procedure++1. Start from one common commit and create `p04-baseline` and `p04-improved`.+2. Seed the same runtime defect in both branches before agent execution.+3. Run Codex or Claude Code with identical defect context and task scope.+4. In baseline, allow default behavior without added enforcement.+5. In improved, require observability additions before defect triage.+6. Verify the fix, then verify no cross-layer violations were introduced.+7. Restart the app to confirm clean, repeatable runtime state.++## What to Measure++- Time to detect root cause of seeded defect.+- Time to confirm verified fix.+- Number of boundary violations introduced during implementation.+- Log usefulness (whether logs directly explain failure mode).+- Clean restart success after fix.++## Deliverables++- Baseline debug run record with defect diagnosis and fix evidence.+- Improved debug run record with observability and structural evidence.+- Structural enforcement artifacts (rules/tests/check scripts).+- Short comparison note on diagnosis speed and fix robustness.diff --git a/projects/project-05-grounded-qa-verification/README.md b/projects/project-05-grounded-qa-verification/README.mdindex ad2c982..e07ca35 100644--- a/projects/project-05-grounded-qa-verification/README.md+++ b/projects/project-05-grounded-qa-verification/README.md@@ -1,12 +1,65 @@# Project 05. Evaluator Loops and Three-Role Upgrades-Goal:+## Objective-- Compare single-agent, evaluator-backed, and three-role harnesses on a- meaningful product upgrade.+Measure how role separation (generator and evaluator, then planner, generator,+and evaluator) changes implementation quality on a substantial product upgrade.-Suggested contents:+## Learning Goals-- `baseline/`-- `stronger/`-- `artifacts/`+- Separate generation from evaluation to improve error detection.+- Apply a rubric-driven review loop instead of subjective quality checks.+- Compare coordination overhead versus output quality across harness designs.++## Task++Choose one substantial upgrade and keep it fixed across all runs:++- Multi-turn Q&A history.+- Citation panel redesign.+- Document collections and filtering.+- Indexing recovery with richer Q&A behavior.++Run three harness variants on the same upgrade scope.++## Baseline Harness Setup++Run 1 uses a single-role harness:++- One agent plans, implements, and self-judges.+- No external evaluator rubric is required.++## Improved Harness Setup++Run 2 and Run 3 use upgraded role separation:++- Run 2: `generator + evaluator`.+- Run 3: `planner + generator + evaluator`.+- Evaluator must score output with the same rubric in both improved runs.++## Procedure++1. Select upgrade scope and define acceptance criteria before coding.+2. Start three branches from the same commit:+ `p05-single`, `p05-gen-eval`, `p05-plan-gen-eval`.+3. Run each branch with Codex or Claude Code using comparable model and budget.+4. Use the same evaluator rubric for all three final outputs.+5. In improved runs, require at least one revision round after evaluator+ feedback.+6. Verify behavior with runnable evidence and record unresolved defects.+7. Compare quality and effort across the three harness variants.++## What to Measure++- Scope definition quality before coding starts.+- Number and severity of defects caught before final handoff.+- Rubric score by category (correctness, reliability, maintainability, UX).+- Rework required after review.+- Final robustness of the upgraded product slice.++## Deliverables++- Single-role run record (prompt, transcript/log, runnable evidence).+- Generator-evaluator run record (including rubric and revision notes).+- Planner-generator-evaluator run record (including rubric and revisions).+- One comparison note summarizing quality gains and coordination costs.diff --git a/projects/project-06-runtime-observability-and-debugging/README.md b/projects/project-06-runtime-observability-and-debugging/README.mdindex f623a32..64741d8 100644--- a/projects/project-06-runtime-observability-and-debugging/README.md+++ b/projects/project-06-runtime-observability-and-debugging/README.md@@ -1,13 +1,70 @@# Project 06. Benchmark, Cleanup, and Capstone Harness-Goal:+## Objective-- Build the strongest course harness, compare it against a weaker baseline on a- fixed task set, and perform cleanup so it is ready for repeated use.+Build and benchmark the course capstone harness, then perform a cleanup cycle+to verify that quality can be maintained over repeated runs.-Suggested contents:+## Learning Goals-- `baseline/`-- `stronger/`-- `cleanup/`-- `artifacts/`+- Run a controlled benchmark on a fixed multi-feature task suite.+- Quantify harness impact on reliability, retries, and defect rate.+- Practice post-run cleanup as a first-class harness responsibility.++## Task++Use a fixed task set that covers the full product slice:++- Import documents.+- Build or refresh an index.+- Answer grounded questions with citations.+- Provide runtime feedback sufficient for debugging.+- Preserve a readable, restartable repository state.++Execute baseline, improved, and post-cleanup rerun comparisons.++## Baseline Harness Setup++Run 1 must use an earlier weaker harness from this course:++- Limited continuity artifacts.+- Weak or partial verification discipline.+- Reduced runtime observability and enforcement.++## Improved Harness Setup++Run 2 must use the strongest harness assembled in the course:++- Continuity artifacts and startup scaffolding.+- Explicit scope and verification gates.+- Runtime signals and structural constraints.+- Evaluator or multi-role review where applicable.++## Procedure++1. Define one fixed benchmark task suite and one scoring sheet before running+ any agent session.+2. Start from one common commit and branch into `p06-baseline` and+ `p06-improved`.+3. Run baseline and improved sessions with Codex or Claude Code using the same+ model and comparable budget.+4. Score both runs immediately after execution.+5. On the improved branch, perform a cleanup pass targeting entropy, dead code,+ unclear docs, and unstable run paths.+6. Rerun the same benchmark task suite after cleanup and rescore.+7. Compare baseline vs improved vs improved-after-cleanup.++## What to Measure++- Benchmark completion rate.+- Number of retries required per task.+- Defect count before human intervention.+- Cleanup effort (time and files touched).+- Post-cleanup legibility and restart success.++## Deliverables++- Baseline benchmark record with scores and evidence.+- Improved benchmark record with scores and evidence.+- Cleanup run record with before/after score delta.+- Final capstone comparison summary with key lessons learned.