/**
 * Build cache context strings from the resolved pipeline configuration.
 *
 * These non-file strings participate in cache key computation so that
 * different CLI filters (mode, variant, area, task, tag) produce
 * distinct cache entries. Without them, running `--mode knowledge-probe`
 * after `--mode literacy` would return cached literacy results.
 *
 * @see packages/core/src/ports/pipeline-step.ts — cacheContext() method
 * @see packages/eval/src/pipeline/cache.ts — hashFiles() context parameter
 */
/**
 * Derive deterministic context strings from the resolved pipeline config.
 *
 * Included in every cacheable step's key so that:
 * - `--mode literacy` and `--mode knowledge-probe` never share cache
 * - `--variant agentic` and `--variant baseline` never share cache
 * - `--area studio` and `--area groq` never share cache
 * - `--task T001` and `--task T002` never share cache
 * - `--tag critical` and `--tag smoke` never share cache
 */
export function buildCacheContext(config) {
    const context = [];
    // Mode is always present — it's required in ResolvedConfig
    context.push(`mode:${config.mode}`);
    // Variant (literacy sub-mode: baseline, agentic, observed, full)
    if (config.variant) {
        context.push(`variant:${config.variant}`);
    }
    // Area filter — sorted for deterministic hashing
    if (config.areas && config.areas.length > 0) {
        context.push(`areas:${[...config.areas].sort().join(",")}`);
    }
    // Task filter — sorted for deterministic hashing
    if (config.tasks && config.tasks.length > 0) {
        context.push(`tasks:${[...config.tasks].sort().join(",")}`);
    }
    // Tag filter — sorted for deterministic hashing
    if (config.tags && config.tags.length > 0) {
        context.push(`tags:${[...config.tags].sort().join(",")}`);
    }
    return context;
}
