| 1 | package org.egothor.methodatlas.command; | |
| 2 | ||
| 3 | import java.io.IOException; | |
| 4 | import java.io.UncheckedIOException; | |
| 5 | ||
| 6 | import org.egothor.methodatlas.ai.AiOptions; | |
| 7 | import org.egothor.methodatlas.ai.TaxonomyVersion; | |
| 8 | ||
| 9 | /** | |
| 10 | * Computes the signature that keys AI result cache entries. | |
| 11 | * | |
| 12 | * <p> | |
| 13 | * Extracted from {@link ScanOrchestrator} to keep that class within the | |
| 14 | * complexity budget; the produced value is part of the cache contract and must | |
| 15 | * stay {@code <promptSignature>|<taxonomyVersion>}. | |
| 16 | * </p> | |
| 17 | */ | |
| 18 | /* default */ final class AiCacheKey { | |
| 19 | ||
| 20 | private AiCacheKey() { | |
| 21 | } | |
| 22 | ||
| 23 | /** | |
| 24 | * Computes the AI cache key signature for a run: the prompt-catalogue signature | |
| 25 | * joined with the resolved taxonomy version. | |
| 26 | * | |
| 27 | * <p> | |
| 28 | * Folding the taxonomy in makes a taxonomy change a cache miss, so every cache | |
| 29 | * hit was classified under the current taxonomy and the {@code ai_taxonomy_version} | |
| 30 | * stamped on emitted records is truthful. | |
| 31 | * </p> | |
| 32 | * | |
| 33 | * @param aiOptions AI options of the current run; must not be {@code null} | |
| 34 | * @return {@code <promptSignature>|<taxonomyVersion>}; never {@code null} | |
| 35 | * @throws IOException if a configured custom taxonomy file cannot be read | |
| 36 | */ | |
| 37 | /* default */ static String signature(AiOptions aiOptions) throws IOException { | |
| 38 |
1
1. signature : replaced return value with "" for org/egothor/methodatlas/command/AiCacheKey::signature → KILLED |
return aiOptions.promptTemplates().signature() + "|" + TaxonomyVersion.resolve(aiOptions); |
| 39 | } | |
| 40 | ||
| 41 | /** | |
| 42 | * Same as {@link #signature(AiOptions)} but rethrows I/O failures unchecked, | |
| 43 | * for use inside lambdas and stream pipelines. | |
| 44 | * | |
| 45 | * @param aiOptions AI options of the current run; must not be {@code null} | |
| 46 | * @return the cache key signature; never {@code null} | |
| 47 | * @throws UncheckedIOException if a configured custom taxonomy file cannot be read | |
| 48 | */ | |
| 49 | /* default */ static String signatureUnchecked(AiOptions aiOptions) { | |
| 50 | try { | |
| 51 |
1
1. signatureUnchecked : replaced return value with "" for org/egothor/methodatlas/command/AiCacheKey::signatureUnchecked → SURVIVED |
return signature(aiOptions); |
| 52 | } catch (IOException e) { | |
| 53 | throw new UncheckedIOException("Cannot resolve taxonomy version for AI cache key", e); | |
| 54 | } | |
| 55 | } | |
| 56 | } | |
Mutations | ||
| 38 |
1.1 |
|
| 51 |
1.1 |