Skip to content

bug: out-of-order tool-inventory passes overwrite newer approvals, index entries and dispatch metadata #1565

Closed

Description

@Dumbris

Problem

Tool-inventory discovery passes can complete out of order, and an older pass overwrites the effects of a newer one. Capture order is not tracked per server and the stores updated by a pass (approval records, search index, StateView/dispatch metadata) are written without a freshness check:

  • applyDifferentialToolUpdate (internal/runtime/lifecycle.go:1018) and the sweep (DiscoverAndIndexTools :369, DiscoverAndIndexToolsForServer :534, ListTools :597, :875) publish whatever inventory they captured.
  • Blocked-tool eviction and added/modified indexing (lifecycle.go:1179-1240) run from a pass's BlockedTools/added set captured earlier, so an overtaken pass can delete a tool that an operator has since approved and reindexed (approved in storage, undiscoverable), or overwrite newer indexed annotations.
  • Absent-tool removal (:724, DeleteToolApprovalIf) from an older inventory can delete the fresh record of a tool that was rediscovered and blocked; if it was the only baseline record, the next pass auto-baselines it as enabled.
  • A rejected/stale inventory must not be published to StateView: dispatch derives target tier from hints, so restoring read-only hints for a now-destructive tool lets a read-scoped caller invoke it.
  • A sweep's single ticket spans servers listed sequentially, and tickets taken before ListTools do not order actual captures (coalesced ListTools), so a genuinely newer definition can be dropped as stale and the change never held.
  • A paused discovery pass that passed its eligibility check can re-index a server that has since been quarantined and purged; the purge in QuarantineServer (lifecycle.go:2175) is not synchronized with passes.
  • Quarantined-definition capture (captureQuarantinedToolDefinitionsFromCurrentClient, lifecycle.go:641) can persist an old endpoint's definitions into the same-name server's review records after an endpoint replacement, because the replaced client keeps its connection epoch until reconciliation.

Note: the core UX-02 per-server mutex fixes lost updates of approval records; it does not order whole passes or protect the index/StateView.

Suggested direction

Assign a monotonic capture ticket per server at actual capture time (inside the managed client's ListTools), validate it under the per-server lock for every store write (records, index, StateView, eviction), and invalidate the captured client identity on retirement. Tests with paused passes for each interleaving above.

Where Sol found it

ux02-r1-A.txt #2, ux02-r2-A.txt #1, ux02-r3-c1.txt #1-#3, ux02-r3-c3.txt #1-#2, ux02-r4-A.txt #1, ux02-r5-chunk1.txt #1, ux01-r9-A.txt #2.


Found by OpenCode Sol 6.1 cross-model review of the (now split) oversized PRs #1553 (UX-01) and #1555 (UX-02); verified still present on origin/main (704795c) by reading the cited sites. Pre-existing, deliberately out of scope of the minimal core PRs. Review transcripts: docs/qa/0.70.0-ux-2026-10-10/remediation/reviews/.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/searchkind/bugpriority/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions