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
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.
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 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.
Clean loop
Green checks, updated progress, and removed artifacts let the next session continue instead of firefighting.
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.
User auth
Verification passing, agent understandable, tests stable, boundaries compliant, conventions followed.
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.
| Approach | Build pass | Test pass | Startup | Stale artifacts |
|---|---|---|---|---|
| No cleanup strategy | 68% | 61% | 60+ min | 103 |
| Clean-state strategy | 97% | 95% | 9 min | 11 |