Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 29 additions & 4 deletions .github/workflows/eval-refresh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -510,15 +510,34 @@ jobs:
echo "::error::Could not cancel run ${{ github.run_id }} after three attempts. The provider-refusal marker stops publish-results, but the remaining cells will keep running and billing: cancel the run by hand."
exit 1

- name: Check artifacts for credentials
# The two uploads below are downloadable by any GitHub account, so they
# are gated on this rather than trusting that every write path redacted.
# It re-applies the harness's redaction passes to every file about to be
# uploaded and fails if any would still remove something, printing the
# file and kind and never the value. A failure here fails the job and
# skips both uploads. The score in the result file is not changed, but
# it is not published either: `publish-results` reads rows from these
# artifacts, so the cell counts as missing, and an earlier row stands
# in for it only where the missing-cell floor allows (#103).
id: artifact-check
if: ${{ !cancelled() }}
shell: bash
run: |
pnpm --filter @hookdeck-evals/framework check-artifacts -- \
".eval-runs/${{ matrix.experiment }}" \
".eval-errored/${{ matrix.experiment }}"

- name: Upload raw results
# Even when the cell failed or errored. The transcript of a failing cell
# is the one somebody actually needs — `regression-alert` tells the
# reader to open it first — and until 5 October it was the only one not
# kept, because this step is skipped by default when an earlier step
# exits non-zero. That cost the transcript of the first real regression
# failure, and had silently cost every errored cell's transcript before
# that: the 21 September run wrote 75 artifacts for 76 jobs.
if: ${{ !cancelled() }}
# that: the 21 September run wrote 75 artifacts for 76 jobs. Never when
# the credential check above failed.
if: ${{ !cancelled() && steps.artifact-check.outcome == 'success' }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: raw-results-${{ matrix.experiment }}__${{ matrix.eval_id }}
Expand Down Expand Up @@ -556,7 +575,8 @@ jobs:
# `raw-results-*` file under `.eval-runs/<experiment>/` and break the
# publish job's copy. The publish job never downloads this one, so
# nothing in it can become a row. Absent for a cell that did not error.
if: ${{ !cancelled() }}
# Gated on the credential check like the upload above.
if: ${{ !cancelled() && steps.artifact-check.outcome == 'success' }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: errored-attempts-${{ matrix.experiment }}__${{ matrix.eval_id }}
Expand Down Expand Up @@ -588,7 +608,12 @@ jobs:
# dispatch is how somebody checks what the schedule enforces, so it
# has to enforce the same thing, and a run's conclusion is only worth
# reading if it means the same on every trigger.
if: ${{ matrix.eval_suite == 'regression' }}
#
# `!cancelled()` so it still runs when the credential check above has
# failed. Without it the implicit `success()` skips this step, and a
# regression cell that is genuinely red would be reported only as a
# credential-check failure. A missing result file still exits 0 below.
if: ${{ !cancelled() && matrix.eval_suite == 'regression' }}
shell: bash
run: |
set -euo pipefail
Expand Down
19 changes: 19 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1329,6 +1329,25 @@ echoed its project key into a transcript on the first real run. Raw results are
gitignored and the export carries no transcripts today, but the guard is there
for when per-run drill-down is added.

**Redacting what the harness injected is not redacting every credential.** The
sandbox can create credentials of its own: `hookdeck ci` mints a CLI key and
writes it to `~/.config/hookdeck/config.toml`, and an agent checking its setup
reasonably `cat`s that file. No env var holds that key, and it has no prefix to
match. So the harness reads the CLI's config files out of each sandbox before
teardown and redacts the values of their credential keys
(`harness/sandbox-credentials.ts`). `redact.ts` also finds any value of 16 or
more characters, containing a letter and a digit, that is assigned to a
credential-marking name (`api_key = '…'`, `"webhook_secret_key": "…"`,
`--webhook-secret …`), and then redacts that value everywhere it appears in
the artifact. `check-artifacts` re-applies those passes before the raw
artifacts are uploaded. If anything is left, the job fails and both uploads
are skipped. The cell's score is unchanged but is not published either:
`publish-results` reads rows from those artifacts, so the cell counts as
missing, and an earlier row stands in only where the missing-cell floor allows
(#103). A new place the sandbox writes a credential needs adding to the
discovery command; a new artifact writer needs to go through
`serializeRedacted`.

## Attribution

This repo is based on [supabase/evals](https://github.com/supabase/evals),
Expand Down
56 changes: 51 additions & 5 deletions apps/framework/harness/errored-cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import {
import { dirname, join, relative, sep } from 'node:path';
import type { AttemptRecord } from './attempts.js';
import { describeError } from './describe-error.js';
import { serializeRedacted, type SecretValue } from './redact.js';
import { type SecretValue, secretValues, serializeRedacted } from './redact.js';
import type { DocsResult, SkillResult, TranscriptPart } from './types.js';

/**
Expand Down Expand Up @@ -100,16 +100,56 @@ export interface ErroredAttemptRecord {
* the cell is done, including through the session and sandbox teardown that
* runs after the loop body. A teardown that throws then still has it.
*
* Mutate it only through the two functions below, which `runOne` calls and
* the tests exercise directly.
* Mutate it only through the functions below, which `runOne` calls and the
* tests exercise directly.
*/
export interface AttemptLoopState {
priorAttempts: AttemptRecord[];
current?: ErroredAttemptRecord;
/**
* Credentials the sandboxes created that the harness did not inject, read
* out of each attempt's container before it was torn down. Every artifact
* this cell writes is redacted with them, the result and the errored-cell
* evidence alike. See `sandbox-credentials.ts`.
*/
discoveredSecrets?: SecretValue[];
}

export function newAttemptLoopState(): AttemptLoopState {
return { priorAttempts: [] };
return { priorAttempts: [], discoveredSecrets: [] };
}

/**
* Add credentials found in an attempt's sandbox. Called before the attempt's
* guards and scorer, so a cell that throws afterwards is still redacted with
* them.
*
* Each distinct value gets its own numbered name, in the order the cell found
* them, so two keys minted by two attempts (or two `hookdeck ci` runs) stay
* distinguishable in the transcript: `<redacted:hookdeck-cli-config:api_key-1>`
* and `…-2`. A value already found keeps the name it was given.
*/
export function credentialsDiscovered(
loop: AttemptLoopState,
secrets: SecretValue[]
): void {
const known = loop.discoveredSecrets ?? [];
const seen = new Set(known.map((s) => s.value));
const added: SecretValue[] = [];
for (const { name, value } of secrets) {
if (seen.has(value)) continue;
seen.add(value);
added.push({ name: `${name}-${known.length + added.length + 1}`, value });
}
loop.discoveredSecrets = [...known, ...added];
}

/** The secrets an artifact from this cell is redacted with. */
export function cellSecrets(
loop: AttemptLoopState,
base: SecretValue[] = secretValues()
): SecretValue[] {
return [...base, ...(loop.discoveredSecrets ?? [])];
}

/**
Expand Down Expand Up @@ -209,7 +249,13 @@ export function writeErroredEvidence(
}
const out = erroredEvidencePath(root, input.experiment, input.evalId);
mkdirSync(dirname(out), { recursive: true });
writeFileSync(out, serializeRedacted(buildErroredEvidence(input), secrets));
writeFileSync(
out,
serializeRedacted(
buildErroredEvidence(input),
cellSecrets(input.state, secrets)
)
);
return out;
}

Expand Down
Loading
Loading