Skip to content

fix(search): prevent cortex_search ANN/HNSW load panic on malformed index state #313

Closed

Description

@hurttlocker

Summary

cortex_search hit a hard panic during live use instead of returning results or falling back cleanly.

Observed error

panic: runtime error: makeslice: len out of range

Current understanding

  • failure happened on the ANN/HNSW load path during cortex_search
  • this was observed in real operator use on 2026-03-10 during an architecture lookup
  • current fallback was to abandon Cortex search for that pass and use memory/web tools instead

Why this matters

This is a reliability issue, not just a rough edge:

  • search should never panic in operator mode
  • malformed/corrupt/unexpected ANN state should degrade gracefully
  • we already hardened one corrupt persisted HNSW path in fix: rebuild on corrupt persisted HNSW index #311, but this suggests there is still an unguarded load/size case left

Acceptance

  • cortex_search no longer panics on this malformed ANN/load state
  • bad ANN state is handled via graceful fallback, rebuild, or explicit bounded error
  • add regression coverage for the failing shape (makeslice: len out of range / malformed length state)
  • document operator-visible behavior if fallback/rebuild is triggered

Notes

This should stay bounded to reliability hardening only; do not widen into broader search/ranking work.

Activity

  1. hurttlocker commented on Mar 11, 2026

    @hurttlocker
    OwnerAuthor

    Local operator re-check: the recurring panic was traced to deployment drift, not just missing repo-side hardening.

    What we found live:

    After rebuilding/installing current main locally (cortex 1.2.4), the same search path now behaves correctly:

    • emits bounded warning
    • rebuilds HNSW
    • returns results instead of panicking

    So this issue should not be treated as a fresh large search-algorithm blocker unless current-main evidence shows a remaining panic. The follow-on hardening move is likely setup/doctor drift detection in #321, not a new emergency search epic.

  2. hurttlocker commented on Mar 11, 2026

    @hurttlocker
    OwnerAuthor

    PR #327 is merged and the recall-lane transparency follow-up is closed. This makes #313 the best next bounded reliability take.

    Recommended scope:

    • reproduce or disprove the ANN/HNSW makeslice: len out of range panic on current main / current DB shape
    • if reproducible, harden the load path so bad ANN state degrades gracefully (bounded error / fallback / rebuild) instead of panicking
    • add a deterministic regression test for the malformed-length load case

    Do not widen into ranking/search-quality work in this lane.

  3. hurttlocker commented on Mar 11, 2026

    @hurttlocker
    OwnerAuthor

    Closing as shipped via PR #328.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions