fix: count active operations and preserve agent roster freshness - #4170
Open
PaleRoses wants to merge 3 commits into
Open
fix: count active operations and preserve agent roster freshness#4170PaleRoses wants to merge 3 commits into
PaleRoses wants to merge 3 commits into
Conversation
…s in one query Two state-reporting fixes on the same API. A knowledge page read answered nothing about freshness. The tree endpoint has always reported per-page is_stale, so a caller that read one page could not tell a current document from one the server already knows is behind its own corpus. get_knowledge_page now computes it with the existing compute_mental_model_is_stale on the connection it already holds, and the HTTP and MCP page payloads carry it. The coding-agent integration carries the flag through listPages and marks such pages STALE in the injected roster, with the legend emitted only when something is flagged. Counting active operations required one request per non-terminal status, and the two counts are taken at different instants: an operation moving from pending to processing between them is missed by both, so the pair can report zero while the bank is still working. The list-operations engine, HTTP and MCP surfaces gain an active_only filter that narrows the endpoint's existing total to pending and processing rows through the same WHERE clause the count already uses, and activeOperations now issues a single limit=1 request and reads that total. That also fixes the older saturation: the previous unfiltered read counted non-terminal rows among the newest page only. Tests pin the two contracts adversarially rather than case by case: one client fixture whose totals and per-status answers defeat page-counting, an unfiltered read and the per-status pair alike, and one HTTP fixture proving `total` counts the filtered set while excluding terminal rows. The OpenAPI spec and docs-skill references were regenerated with the repository's scripts. The Go, Python and TypeScript clients and hindsight-clients/go/api/openapi.yaml were mirrored by hand in the shape of commit 8f6e0e5, because the client generator requires Docker, which was unavailable in the environment where this was prepared.
PaleRoses
force-pushed
the
fix/page-staleness-and-active-operation-count
branch
from
September 6, 2026 23:20
63616ce to
855de9f
Compare
Keep the server-side active-operation count and carry tree freshness through injected rosters. Restore upstream page reads, exports and response schemas without extra per-page freshness queries. Regenerate SDKs and replace projection/source-text checks with consumer regressions. Verified 387 backend tests and 879 coding-agent tests; three client regressions fail against upstream. TypeScript, Ruff, Python type checks, SDK builds, the Rust CLI and isolated native status/SessionStart smoke checks passed. Live deployment unchanged.
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.
Scope
active_onlyto operation listing (HTTP, MCP and generated SDKs). It filters pending/processing records before counting; the coding-agent client reads that total rather than filtering the newest 20 results. Unavailable or malformed counts are not reported as zero.is_staleflag through the coding-agent client into SessionStart and periodic rosters. Unknown freshness stays unmarked; a refreshed page loses its stale marker.Individual page reads, exports, response schemas and the control-plane freshness path remain unchanged. This revision removes the proposed per-page freshness queries.
Reproduction and boundaries
Upstream reports zero active operations when its newest 20 records are completed and an older operation remains pending. Its page-list adapter also discards a true freshness flag already present in the tree.
The exact count includes deferred/parked operations. Existing bank-wide readiness and settle policies are unchanged; a busy shared bank can still reach the settle deadline. Older servers ignoring
active_onlyreturn the full history total, an overcount.Verification
No live deployment, private-bank migration, full-monorepo suite or live-provider testing.