@sanity/ailf 0.1.15 → 0.1.16

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.
@@ -99,6 +99,17 @@ export interface ResolvedConfig {
99
99
  reportStoreProjectId?: string;
100
100
  /** Report store dataset from .ailf/config.yaml reportStore block */
101
101
  reportStoreDataset?: string;
102
+ /**
103
+ * Git metadata from the *calling* repository (cross-repo evaluations).
104
+ * When set, this overrides the CI env var-based git detection in provenance,
105
+ * ensuring the report attributes to the caller — not the AILF core repo.
106
+ */
107
+ callerGit?: {
108
+ branch?: string;
109
+ prNumber?: number;
110
+ repo: string;
111
+ sha?: string;
112
+ };
102
113
  /** Callback URL configuration for API-triggered evaluations */
103
114
  callback?: {
104
115
  url: string;
@@ -20,6 +20,12 @@ export declare const PipelineRequestSchema: z.ZodObject<{
20
20
  "cloud-run": "cloud-run";
21
21
  }>>;
22
22
  areas: z.ZodOptional<z.ZodArray<z.ZodString>>;
23
+ callerGit: z.ZodOptional<z.ZodObject<{
24
+ branch: z.ZodOptional<z.ZodString>;
25
+ prNumber: z.ZodOptional<z.ZodNumber>;
26
+ repo: z.ZodString;
27
+ sha: z.ZodOptional<z.ZodString>;
28
+ }, z.core.$strip>>;
23
29
  callback: z.ZodOptional<z.ZodObject<{
24
30
  headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
25
31
  url: z.ZodString;
@@ -30,12 +30,31 @@ const CallbackSchema = z.object({
30
30
  url: z.string().url(),
31
31
  });
32
32
  // ---------------------------------------------------------------------------
33
+ // Caller Git context — for cross-repo evaluations
34
+ // ---------------------------------------------------------------------------
35
+ /**
36
+ * Git metadata from the *calling* repository.
37
+ *
38
+ * When a cross-repo evaluation is triggered (via repository_dispatch or
39
+ * the API), the GitHub Actions env vars (GITHUB_REPOSITORY, GITHUB_SHA,
40
+ * etc.) reflect the *AILF core repo* where the workflow executes — not
41
+ * the repo that requested the evaluation. This field carries the caller's
42
+ * actual git context so provenance correctly attributes the evaluation.
43
+ */
44
+ const CallerGitSchema = z.object({
45
+ branch: z.string().optional(),
46
+ prNumber: z.number().int().positive().optional(),
47
+ repo: z.string(),
48
+ sha: z.string().optional(),
49
+ });
50
+ // ---------------------------------------------------------------------------
33
51
  // Pipeline Request — the universal invocation contract
34
52
  // ---------------------------------------------------------------------------
35
53
  export const PipelineRequestSchema = z.object({
36
54
  allowedOrigins: z.array(z.string()).optional(),
37
55
  backend: z.enum(["github-actions", "cloud-run"]).optional(),
38
56
  areas: z.array(z.string()).optional(),
57
+ callerGit: CallerGitSchema.optional(),
39
58
  callback: CallbackSchema.optional(),
40
59
  changedDocs: z.array(z.string()).optional(),
41
60
  compare: z.boolean().optional(),
@@ -146,6 +146,7 @@ function buildProvenanceInput(summary, ctx, options) {
146
146
  : undefined;
147
147
  return {
148
148
  areas,
149
+ callerGit: ctx.config.callerGit,
149
150
  evalFingerprint,
150
151
  mode,
151
152
  promptfooUrls: options.promptfooUrls,
@@ -56,6 +56,7 @@ export function mapRequestToConfig(request, rootDir) {
56
56
  sanityDocumentArgs: undefined,
57
57
  beforeOption: undefined,
58
58
  repoTasksPath: undefined,
59
+ callerGit: request.callerGit,
59
60
  callback: request.callback,
60
61
  jobId: request.jobId,
61
62
  remote: false,
@@ -16,6 +16,17 @@ import type { EvalMode, PromptfooUrlEntry, ReportProvenance } from "./types.js";
16
16
  export interface ProvenanceInput {
17
17
  /** Feature areas that were evaluated */
18
18
  areas: string[];
19
+ /**
20
+ * Git metadata from the *calling* repository (cross-repo evaluations).
21
+ * When provided, overrides CI env var detection so provenance attributes
22
+ * to the caller — not the AILF core repo where the workflow executes.
23
+ */
24
+ callerGit?: {
25
+ branch?: string;
26
+ prNumber?: number;
27
+ repo: string;
28
+ sha?: string;
29
+ };
19
30
  /** SHA-256 hash of the doc context files (from cache system) */
20
31
  contextHash?: string;
21
32
  /** Evaluation fingerprint for cross-environment cache lookup */
@@ -25,11 +25,21 @@ import { load } from "js-yaml";
25
25
  */
26
26
  export function buildProvenance(input) {
27
27
  const models = loadModelsConfig(input.rootDir);
28
+ // Cross-repo evaluations: prefer explicit caller git metadata over
29
+ // CI env vars (which always reflect the AILF core repo).
30
+ const git = input.callerGit
31
+ ? {
32
+ branch: input.callerGit.branch ?? "unknown",
33
+ prNumber: input.callerGit.prNumber,
34
+ repo: input.callerGit.repo,
35
+ sha: input.callerGit.sha ?? "unknown",
36
+ }
37
+ : detectGitMetadata();
28
38
  return {
29
39
  areas: input.areas,
30
40
  contextHash: input.contextHash,
31
41
  evalFingerprint: input.evalFingerprint,
32
- git: detectGitMetadata(),
42
+ git,
33
43
  graderModel: models.grader.id,
34
44
  mode: input.mode,
35
45
  models: models.models.map((m) => ({ id: m.id, label: m.label })),
@@ -110,6 +120,9 @@ function detectTrigger() {
110
120
  if (eventName === "repository_dispatch") {
111
121
  return {
112
122
  callerRef: process.env.GITHUB_REF,
123
+ // Note: callerRepo here is a fallback. The accurate caller repo
124
+ // comes from callerGit (injected into the PipelineRequest payload).
125
+ // GITHUB_REPOSITORY_OWNER_ID is just the org ID, not owner/repo.
113
126
  callerRepo: process.env.GITHUB_REPOSITORY_OWNER_ID ?? "unknown",
114
127
  type: "cross-repo",
115
128
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/ailf",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "restricted"