Skip to content

fix: count active operations and preserve agent roster freshness - #4170

Open
PaleRoses wants to merge 3 commits into
vectorize-io:mainfrom
PaleRoses:fix/page-staleness-and-active-operation-count
Open

fix: count active operations and preserve agent roster freshness#4170
PaleRoses wants to merge 3 commits into
vectorize-io:mainfrom
PaleRoses:fix/page-staleness-and-active-operation-count

Conversation

@PaleRoses

@PaleRoses PaleRoses commented Sep 6, 2026

Copy link
Copy Markdown

Scope

  • Add active_only to 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.
  • Preserve the knowledge tree's existing is_stale flag 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_only return the full history total, an overcount.

Verification

  • 387 backend tests passed across operation status, async batch retain, MCP tools and knowledge-base suites, using mock LLMs and an isolated PostgreSQL instance.
  • 879 coding-agent tests passed across 67 files; TypeScript, formatting and bundle build passed. Three retained regressions fail against upstream: truncated counting, fabricated zero on unavailable counts, and missing stale markers. Three source-text assertions were removed; behavioral coverage remains.
  • Built status CLI reports the older pending operation; built Claude SessionStart hook emits the stale marker and leaves the fresh page unmarked. Both ran against a read-only HTTP fixture.
  • OpenAPI, documentation projections and SDKs regenerated with the pinned generators. Rust SDK, Go SDK, TypeScript SDK and Rust CLI builds passed; Ruff and Python type checks passed.

No live deployment, private-bank migration, full-monorepo suite or live-provider testing.

…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.
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.
@PaleRoses PaleRoses changed the title fix: report page staleness on a page read, and count active operations in one query fix: count active operations and preserve agent roster freshness Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant