Skip to content

[index] DepIndexCache round-trip only tests type ids; term-id codec path untested #77

Description

@rochala

Severity: low — test coverage gap. The codec path likely works, but a regression here would be invisible.

Symptom

DepIndexCacheSpec.sample only builds type ids via IndexTestFixtures.tid:

private def sample(name: String): IndexedSymbol = IndexedSymbol(
  id = IndexTestFixtures.tid(s"com.example.$name"),  // member = None always
  ...
  parents = List(IndexTestFixtures.tid("java.lang.Object")),
  ...
)

The codec rewrite in Phase 1 dropped the custom JsonValueCodec[SymbolId] and now derives the structural codec via JsonCodecMaker.make[List[IndexedSymbol]]. Type ids (Option[Member] = None) round-trip in tid-only tests, but the term-id branch (Some(Member(disambig = None))) — used by every method/field a real BytecodeIndexer emits — is exercised only at runtime against real fixtures, not in the cache spec.

A future codec regression that mishandles Some(Member(None)) (e.g. flattening to null on read) would silently corrupt cached term ids on the next cold start. DepIndexCache.Version = 3 only invalidates pre-Phase-1 caches; this regression would survive bumps.

Fix

Add a term-id round-trip test to DepIndexCacheSpec:

test("store/lookup roundtrips a term-id symbol") {
  val termSym = sample("Foo").copy(id = IndexTestFixtures.mid("com.example.Foo.bar"))
  for {
    (cache, _) <- freshCache
    _          <- cache.store("abc", List(termSym))
    result     <- cache.lookup("abc")
  } yield expect(result.contains(List(termSym)))
}

Acceptance criteria

  • New DepIndexCacheSpec test exercising term-id round-trip
  • Same test verifies parents containing term ids round-trip too (composite case)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions