Skip to content

0013 Entity cap skips rather than breaks

Status

Accepted

Context

applyEntityCap() limits the Sources list to a maximum number of distinct entities. Stopping the loop as soon as the cap is reached would also drop any later chunk belonging to an entity already kept, even though that chunk might carry a citation-worthy detail the earlier chunk didn't.

Decision

applyEntityCap() keeps iterating past the cap, skipping only chunks whose entity isn't already in the kept set. A chunk belonging to an already-included entity is always kept, regardless of its position in the source list.

Consequences

  • The total chunk count returned isn't bounded by the entity cap, only the distinct-entity count is. Callers must not assume the result has at most $cap items.
  • This favors completeness of already-included entities over strict truncation by relevance rank: a lower-scored chunk of an entity already kept survives ahead of a higher-scored chunk of a new entity once the cap is reached.