NumPy allowed · plain Python earns 10 bonus points
Cosine-like similarity scores ranked before context assembly
Implement context-window budget fitting: greedily including the highest-scored retrieved chunks until the token budget runs out.
Implement fit_context_budget(chunks, token_budget). chunks is a list of {"id": str, "text": str, "score": float, "tokens": int}. Sort by score descending, then greedily include chunks (in that order) as long as the running token total stays <= token_budget. Return the included chunks' ids in the order they were included.
fit_context_budget(chunks: list[dict], token_budget: int) -> list[str]