Repository navigation
docs: propose hoisting the read ledger + a session-owned extensible state data model - #1025
Conversation
Co-Authored-By: mecatl <[email protected]>
Co-Authored-By: mecatl <[email protected]>
Co-Authored-By: mecatl <[email protected]>
Co-Authored-By: mecatl <[email protected]>
Co-Authored-By: mecatl <[email protected]>
Co-Authored-By: mecatl <[email protected]>
This reverts commit bd04c76.
Co-Authored-By: mecatl <[email protected]>
Co-Authored-By: mecatl <[email protected]>
Co-Authored-By: mecatl <[email protected]>
Co-Authored-By: mecatl <[email protected]>
Co-Authored-By: mecatl <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR adds a working-draft scoping document proposing that read-before-write observation state (“read ledger”) should be session-owned extensible state, and updates the existing scoped resource grants scoping doc and generated llms.txt corpus index to reference it.
Changes:
- Add
docs/session-state-and-read-ledger.mddescribing a session-owned, namespaced key/value state model and how it could host a read ledger. - Update
docs/scoped-resource-grants.mdto link to the new proposal as a companion doc. - Regenerate
llms.txtto reflect the added document and updated corpus statistics/ordering.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| llms.txt | Regenerated corpus index including the new scoping document and updated link graph stats. |
| docs/session-state-and-read-ledger.md | New strawman proposal doc for session-owned extensible state + read-ledger boundary. |
| docs/scoped-resource-grants.md | Cross-links scoped resource grants scoping doc to the new session-state/read-ledger proposal. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| This proposal does not specify the migration sequence or implementation tasks. | ||
| In particular, it does not: |
| PR #946 makes an important first separation: `Workspace` becomes content-only | ||
| and a new `tool.ReadLedger` is carried separately by `Environment`. It also | ||
| proves in-memory and Redis ledger implementations. That solves independent |
| The agent-facing Read tool calls the decorator's ordinary `Read` operation: | ||
|
|
||
| ```text | ||
| Read(path) | ||
| 1. raw Workspace.ReadVersion(path) → content, version |
|
|
||
| ## Extensible session state | ||
|
|
||
| ### A generic session-scoped state facility |
There was a problem hiding this comment.
I haven't dug into how sessions are persisted, tbh. Are they saved as one big blob or are the streamed out to storage incrementally as the session progresses? What does this mean for the ledger? Does it update and persist to storage after every file operation or does it have a way to stream? I'm guessing we can start with writing the whole ledger out after each operation but perhaps move to some sort of append only log with a compact step if need be. It is likely any database already implements that so this would only save network and encode CPU cost. Probably ok for a ledger that is <100 files but if things go beyond that there may be a need to optimize.
There was a problem hiding this comment.
Agreed. Exact-key key-value access is the best initial contract for the ledger because it persists and retrieves one observed path without loading or serializing the whole ledger. I clarified that this minimizes read amplification, while key-value need not be the only contract the session-state facility eventually supports. The facility’s purpose is to give features one session-owned persistence and lifecycle mechanism so each feature does not have to solve backend storage independently.
|
|
||
| ### Lazy restoration | ||
|
|
||
| Loading a session should not require loading every observed path. Instead, the |
There was a problem hiding this comment.
Ideally, when the ledger writes something out, the session also stores the current session version (turn number?) so that if things get out of sync we don't read an old ledger and assume it is good. Probably best effort there is to drop the ledger and force the agent to re-read everything before writing. That should be a rare case.
There was a problem hiding this comment.
Agreed. I added a fail-closed requirement that restored extensible state may be used only when the persistence layer can establish that it corresponds to the restored Session state. If it cannot, ledger evidence is treated as absent and the agent must Read again. The implementation ADR will determine whether this is enforced with a revision, generation, transaction, or another mechanism.
| └── attach State(session-A) | ||
| └── no ledger entries loaded yet | ||
|
|
||
| first lookup of file/read-ledger/v1 + "src/a.go" |
There was a problem hiding this comment.
This implies that there is a key in redis per file. That wasn't clear above and alleviates some of the concerns if we persist this on every file operation.
| grant design. The session-state facility proposed here provides a place to | ||
| retain observations once reported, without prescribing the grant wire shape. | ||
|
|
||
| ## Open questions |
There was a problem hiding this comment.
Just brainstorming on a possible future direction. I know that some harnesses expose a way to edit a file based on a diff like mechanism whereby the agent describes the surrounding text and allows for edits as long as that area of the file hasn't been touched. I don't think anything here makes that harder.
There was a problem hiding this comment.
Agreed. Moving the ledger into the engine does not prevent us from adding region- or diff-based edits in the future. That would be a separate enhancement to the editing model.
jbeda
left a comment
There was a problem hiding this comment.
One last comment - as I was reading the implementation, it occurs to me that we only keep track of the latest version that the agent read but it can do partial reads. We could/might want to track which parts of the file the agent read and not let it write to parts outside of what it read. That would be an expansion of what we do today so out of scope but something to think about.
Co-Authored-By: mecatl <[email protected]>
Co-Authored-By: mecatl <[email protected]>
Summary
This scoping document proposes moving read-before-write observation state and enforcement into the engine, where it follows the Session lifecycle.
Scope
This is a working design proposal, not an implementation or frozen ADR. It deliberately defers the exact Go API, generic type shape, serialization format, and backend storage layout to an implementation ADR. It does not change existing read-before-write, stale-read, create-only, final-CAS, or Bash behavior.
Validation
git diff --checkllms.txtwith the CI-pinned matlatl revision