Add structured log cursor reads#555
Open
Clubhouse1661 wants to merge 1 commit into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This adds a reliable cursor API for structured log buffers. The main goal is to make editor diagnostics safe to read from a known point in time, even when the log ring fills up or gets cleared.
Before this change,
McpEditorLogBuffer.total_count()only represented the number of entries currently retained in the ring. Once the ring reached its max size, that value stopped increasing. That makes it unsafe to use as a cursor for “show me entries after this point,” especially during an error storm, where old entries may be overwritten.This change adds a separate monotonic append counter that keeps moving forward on every append.
What Changed
Added
_appended_totaltoMcpStructuredLogRing.Added
appended_total().Added
get_since(cursor, limit).truncated: trueif the cursor is older than the oldest retained entry.limitandhas_more.next_cursorso callers can continue from the right point.Added mutex-wrapped
appended_total()andget_since()methods toMcpEditorLogBuffer.Added regression tests for:
clear()preserving the append counterclear()reporting truncation instead of looking cleanWhy
This is groundwork for attaching diagnostics directly to write operations.
For example, a future script or resource write can:
That avoids treating the retained ring size as a clock, which breaks once the ring is full.
Validation
test_run suite="editor": 119 passed, 0 failed, 2 skippeduv run python -m pytest tests/unit -q --ignore=tests/unit/test_orphan_reaper.py: 862 passed, 6 skippedGodot 4.6.3 --headless --path test_project --import: passedgit diff --check: clean