@sanity/ailf 0.1.26 → 0.1.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -438,6 +438,12 @@ export interface PipelineState {
|
|
|
438
438
|
evalFingerprint?: string;
|
|
439
439
|
/** Promptfoo share URLs produced by RunEvalStep, consumed by PublishReportStep */
|
|
440
440
|
promptfooUrls?: PromptfooUrlEntry[];
|
|
441
|
+
/**
|
|
442
|
+
* Eval modes that were satisfied by a remote cache hit (score-summary.json
|
|
443
|
+
* was restored from the Content Lake). Produced by RunEvalStep, consumed by
|
|
444
|
+
* CalculateScoresStep to skip re-calculation when all required modes are cached.
|
|
445
|
+
*/
|
|
446
|
+
remoteCacheHits?: Set<string>;
|
|
441
447
|
/**
|
|
442
448
|
* Release auto-scope metadata. Set by FetchDocsStep when a perspective
|
|
443
449
|
* is active and release impact identifies affected documents.
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* Calls calculateAndWriteScores() from pipeline/calculate-scores.ts with
|
|
5
5
|
* typed options derived from AppContext. No env bridge needed.
|
|
6
6
|
*/
|
|
7
|
-
import type { AppContext, PipelineStep, StepResult, ValidationIssue } from "../../_vendor/ailf-core/index.d.ts";
|
|
7
|
+
import type { AppContext, PipelineState, PipelineStep, StepResult, ValidationIssue } from "../../_vendor/ailf-core/index.d.ts";
|
|
8
8
|
export declare class CalculateScoresStep implements PipelineStep {
|
|
9
9
|
readonly name = "calculate-scores";
|
|
10
10
|
check(): ValidationIssue[];
|
|
11
|
-
execute(ctx: AppContext): Promise<StepResult>;
|
|
11
|
+
execute(ctx: AppContext, state: PipelineState): Promise<StepResult>;
|
|
12
12
|
cacheInputs(ctx: AppContext): string[];
|
|
13
13
|
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* typed options derived from AppContext. No env bridge needed.
|
|
6
6
|
*/
|
|
7
7
|
import { join } from "path";
|
|
8
|
+
import { FULL_MODE_SUBMODES } from "../../_vendor/ailf-shared/index.js";
|
|
8
9
|
import { getStepInputPaths } from "../../pipeline/cache.js";
|
|
9
10
|
import { calculateAndWriteScores } from "../../pipeline/calculate-scores.js";
|
|
10
11
|
import { checkResultsExist, checkScoreSummaryValid, } from "../../pipeline/checks.js";
|
|
@@ -16,8 +17,29 @@ export class CalculateScoresStep {
|
|
|
16
17
|
check() {
|
|
17
18
|
return [];
|
|
18
19
|
}
|
|
19
|
-
async execute(ctx) {
|
|
20
|
+
async execute(ctx, state) {
|
|
20
21
|
const start = Date.now();
|
|
22
|
+
// When all required eval modes were satisfied by remote cache hits,
|
|
23
|
+
// score-summary.json was already restored from the cached report.
|
|
24
|
+
// Skip re-calculation — the raw eval-results files don't exist.
|
|
25
|
+
if (state.remoteCacheHits?.size) {
|
|
26
|
+
const requiredModes = ctx.config.mode === "full"
|
|
27
|
+
? [...FULL_MODE_SUBMODES]
|
|
28
|
+
: [ctx.config.mode];
|
|
29
|
+
const allCached = requiredModes.every((m) => state.remoteCacheHits.has(m));
|
|
30
|
+
if (allCached) {
|
|
31
|
+
// Verify the restored score-summary.json is valid
|
|
32
|
+
const summaryIssues = checkScoreSummaryValid(ctx.config.rootDir);
|
|
33
|
+
const summaryErrors = summaryIssues.filter((i) => i.severity === "error");
|
|
34
|
+
if (summaryErrors.length === 0) {
|
|
35
|
+
return {
|
|
36
|
+
reason: "Remote cache hit — score-summary.json restored from cached report",
|
|
37
|
+
status: "skipped",
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
// If the summary is invalid, fall through to normal calculation
|
|
41
|
+
}
|
|
42
|
+
}
|
|
21
43
|
const primaryMode = ctx.config.mode === "full"
|
|
22
44
|
? "baseline"
|
|
23
45
|
: ctx.config.mode;
|
|
@@ -102,6 +102,10 @@ export class RunEvalStep {
|
|
|
102
102
|
ctx.reportStore) {
|
|
103
103
|
const remoteCacheResult = await checkRemoteCache(evalFingerprint, ctx.reportStore, rootDir);
|
|
104
104
|
if (remoteCacheResult) {
|
|
105
|
+
// Record the cache hit so CalculateScoresStep can skip when all
|
|
106
|
+
// required eval modes were satisfied from the remote cache.
|
|
107
|
+
state.remoteCacheHits ??= new Set();
|
|
108
|
+
state.remoteCacheHits.add(this.mode);
|
|
105
109
|
return {
|
|
106
110
|
durationMs: Date.now() - start,
|
|
107
111
|
status: "success",
|