diff --git a/packages/agent/docs/harness.md b/packages/agent/docs/harness.md index 5182c08a9..9e38c1fab 100644 --- a/packages/agent/docs/harness.md +++ b/packages/agent/docs/harness.md @@ -1,5 +1,80 @@ # AgentHarness — implementation specification +- [Part 0 — Orientation](#part-0--orientation) + - [0.1 What this is](#01-what-this-is) + - [0.2 System model](#02-system-model) + - [0.3 The three stores](#03-the-three-stores) + - [0.4 Worked example — a Slack thread](#04-worked-example--a-slack-thread) + - [0.5 Worked example — a crash mid-tool](#05-worked-example--a-crash-mid-tool) + - [0.6 Non-goals](#06-non-goals) + - [0.7 Notation and source types](#07-notation-and-source-types) +- [Part 1 — Storage](#part-1--storage) + - [1.1 The model](#11-the-model) + - [1.2 Identity](#12-identity) + - [1.3 Register namespaces](#13-register-namespaces) + - [1.4 Transactions](#14-transactions) + - [1.5 Queries](#15-queries) + - [1.6 Usage ledger](#16-usage-ledger) + - [1.7 Backends](#17-backends) + - [1.8 Why write-once plus registers](#18-why-write-once-plus-registers) +- [Part 2 — The conversation tree](#part-2--the-conversation-tree) + - [2.1 Entries](#21-entries) + - [2.2 Placement](#22-placement) + - [2.3 Lanes](#23-lanes) + - [2.4 Facts](#24-facts) + - [2.5 Branch queries and context](#25-branch-queries-and-context) + - [2.6 The branch index](#26-the-branch-index) + - [2.7 Forks](#27-forks) + - [2.8 Session and repository boundary](#28-session-and-repository-boundary) + - [2.9 The precise rewrite](#29-the-precise-rewrite) +- [Part 3 — The operation state machine](#part-3--the-operation-state-machine) + - [3.1 Operations](#31-operations) + - [3.2 Operation state — the program counter](#32-operation-state--the-program-counter) + - [3.3 Lane state and current-state validity](#33-lane-state-and-current-state-validity) + - [3.4 The atomic transition rule](#34-the-atomic-transition-rule) + - [3.5 The graph](#35-the-graph) + - [3.6 Acceptance](#36-acceptance) + - [3.7 Assistant generation](#37-assistant-generation) + - [3.8 Tools](#38-tools) + - [3.9 Summary generation — compaction and navigation summaries](#39-summary-generation--compaction-and-navigation-summaries) + - [3.10 Navigation](#310-navigation) + - [3.11 Inbox, queues, deferred writes](#311-inbox-queues-deferred-writes) + - [3.12 The checkpoint procedure](#312-the-checkpoint-procedure) + - [3.13 Terminal transactions](#313-terminal-transactions) +- [Part 4 — Execution, recovery, abort, close](#part-4--execution-recovery-abort-close) + - [4.1 The interpreter](#41-the-interpreter) + - [4.2 The effects boundary](#42-the-effects-boundary) + - [4.3 The lane mutation line](#43-the-lane-mutation-line) + - [4.4 Restore](#44-restore) + - [4.5 Crash positions and recovery policy](#45-crash-positions-and-recovery-policy) + - [4.6 Abort](#46-abort) + - [4.7 Close — a controlled crash](#47-close--a-controlled-crash) + - [4.8 Faults](#48-faults) + - [4.9 External finalization](#49-external-finalization) +- [Part 5 — Public surface](#part-5--public-surface) + - [5.1 The lane surface](#51-the-lane-surface) + - [5.2 The harness](#52-the-harness) + - [5.3 SessionTree](#53-sessiontree) + - [5.4 Snapshots and subscription](#54-snapshots-and-subscription) + - [5.5 Events](#55-events) + - [5.6 Hooks](#56-hooks) + - [5.7 Agent-loop building blocks](#57-agent-loop-building-blocks) + - [5.8 Telemetry](#58-telemetry) +- [Part 6 — Future: partitioned retention (Postgres)](#part-6--future-partitioned-retention-postgres) +- [Part 7 — Schema evolution](#part-7--schema-evolution) + - [7.1 The problem](#71-the-problem) + - [7.2 Why this design shrinks the problem](#72-why-this-design-shrinks-the-problem) + - [7.3 The mechanism: storage version plus migrate-on-open](#73-the-mechanism-storage-version-plus-migrate-on-open) + - [7.4 Migrations are total](#74-migrations-are-total) + - [7.5 The three strata, restated as policy](#75-the-three-strata-restated-as-policy) +- [Part 8 — Build order](#part-8--build-order) +- [Part 9 — Invariants and tests](#part-9--invariants-and-tests) + - [9.1 Invariants](#91-invariants) + - [9.2 Race catalog](#92-race-catalog) + - [9.3 Test tiers](#93-test-tiers) +- [Appendix A — Glossary](#appendix-a--glossary) +- [Appendix B — Coding-agent v3-format compatibility](#appendix-b--coding-agent-v3-format-compatibility) +- [Appendix C — Open questions](#appendix-c--open-questions) # Part 0 — Orientation ## 0.1 What this is