Harness Notes
Lecture 12

Leave a clean handoff at the end of every session

Long-term reliability depends on operational discipline: the next session inherits the state you leave behind.

Notes from Learn Harness Engineering - Lecture 12

session_exitclean handoff
01Build passesverified, not assumedpass
02Tests passincluding pre-existing testspass
03Progress recordedfeature list and notes updatedpass
04Artifacts removedno debug files or stale TODOspass
05Startup worksnext session can beginpass

Entropy growth is the default.

Agents copy patterns already present in a repository, even when those patterns are inconsistent. If each session exits messy, drift compounds until the next session spends its first 30 minutes just reconstructing what happened.

Broken checks

Build or tests fail, so the next task starts with repair work.

Opaque progress

The feature list does not say what passed, what is active, or what remains.

Stale artifacts

Debug logs, temp files, commented code, and TODOs raise cognitive load.

Startup friction

Environment, context loading, or task selection needs manual intervention.

Clean state is more than "the code compiles."

A session is not complete until task verification and clean-state verification both pass.

Feature work completeBuild passes?Tests pass?Record progressRemove artifactsStartup works?

ANY NO -> FIX BEFORE EXIT -> RERUN THE CHECK

Core concepts

Treat session exit like a transaction: either leave a consistent handoff, or keep fixing until you can.

Clean stateBuild passes, tests pass, progress recorded, no stale artifacts, startup path available.
Session integrityDatabase-transaction thinking for coding sessions: fully commit cleanly or return to consistency.
Quality documentActive module-health artifact tracking verification, understandability, tests, boundaries, and conventions.
Cleanup loopRoutine maintenance session that reduces entropy before it becomes emergency debt.
Harness simplificationPeriodically remove constraints that stronger models no longer need.
Idempotent cleanupCleanup can run repeatedly and safely produce the same end state.

"Clean up later" means never clean up.

Dirty loop

Red tests, temp files, and missing progress force diagnosis, then new work piles on top of uncertain state.

dirty exit
diagnose first
modify fragile repo
more dirty exit
vs.

Clean loop

Green checks, updated progress, and removed artifacts let the next session continue instead of firefighting.

clean exit
fast startup
continue coding
clean exit

How to do it

Make clean state required.

Session completion = task verification passes and clean-state check passes.

Use two cleanup modes.

Immediate cleanup at every session end; periodic weekly cleanup for structural drift.

Maintain quality documents.

Track module quality and prioritize the lowest-scoring modules first.

Simplify the harness monthly.

Disable one component, run benchmark tasks, and remove it if results do not degrade.

## Session Exit Checklist
- [ ] Build passes (npm run build)
- [ ] All tests pass (npm test)
- [ ] Feature list updated
- [ ] No debug code remains
- [ ] Standard startup path works (npm run dev)

Quality documents make health visible.

A quality document is not a one-time review. It is a living map of which modules are getting stronger or weaker.

Quality A

User auth

Verification passing, agent understandable, tests stable, boundaries compliant, conventions followed.

Quality C

Payment module

Callback partially untested, logic spread across three files, flaky tests, boundary violations present.

Harnesses should also get cleaned up.

As models improve, some constraints become unnecessary overhead. The useful harness combinations do not disappear; they shift toward the next capability boundary.

Disable one component

Choose a harness mechanism and turn it off temporarily.

Run benchmark tasks

Compare completion quality, drift, retry count, and defect escape rate.

Keep, remove, or replace

If results do not degrade, remove it. If they do, restore or lighten it.

Twelve-week comparison

The cleanup strategy adds about five minutes at session exit, but prevents dozens of hours of later chaos.

ApproachBuild passTest passStartupStale artifacts
No cleanup strategy68%61%60+ min103
Clean-state strategy97%95%9 min11

Why it matters

29 pts
build delta
week 12
34 pts
test delta
week 12
85%
faster startup
with cleanup
60-80%
less diagnosis
with good progress records
TAKEAWAY

The session is not done until the next session can start without cleaning up after it.