Files
wehub-resource-sync 0d3cb498a3
Deploy local.promptfoo.app / Deploy to Cloudflare Pages (push) Waiting to run
Test and Publish Multi-arch Docker Image / test (push) Waiting to run
Test and Publish Multi-arch Docker Image / build-docker-and-push-digests (map[digest-suffix:linux-amd64 platform:linux/amd64 runner:ubuntu-latest]) (push) Blocked by required conditions
Test and Publish Multi-arch Docker Image / build-docker-and-push-digests (map[digest-suffix:linux-arm64 platform:linux/arm64 runner:ubuntu-24.04-arm]) (push) Blocked by required conditions
Test and Publish Multi-arch Docker Image / merge-docker-digests (push) Blocked by required conditions
Test and Publish Multi-arch Docker Image / Attest Multi-arch Image (push) Blocked by required conditions
Validate Renovate Config / Validate Renovate Configuration (push) Waiting to run
CI / Shell Format Check (push) Has been cancelled
CI / Check Ruby (3.4) (push) Has been cancelled
CI / CI Config (push) Has been cancelled
CI / Test on Node ${{ matrix.node }} and ${{ matrix.os }}${{ matrix.shard && format(' (shard {0}/3)', matrix.shard) || '' }} (push) Has been cancelled
CI / Build on Node ${{ matrix.node }} (push) Has been cancelled
CI / Style Check (push) Has been cancelled
CI / Generate Assets (push) Has been cancelled
CI / Check Python (3.14) (push) Has been cancelled
CI / Check Python (3.9) (push) Has been cancelled
CI / Build Docs (push) Has been cancelled
CI / Code Scan Action (push) Has been cancelled
CI / Site tests (push) Has been cancelled
CI / webui tests (push) Has been cancelled
CI / Run Integration Tests (push) Has been cancelled
CI / Run Smoke Tests (push) Has been cancelled
CI / Go Tests (push) Has been cancelled
CI / Share Test (push) Has been cancelled
CI / Redteam (Production API) (push) Has been cancelled
CI / Redteam (Staging API) (push) Has been cancelled
CI / GitHub Actions Lint (push) Has been cancelled
CI / Check Ruby (3.0) (push) Has been cancelled
release-please / release-please (push) Has been cancelled
release-please / build (push) Has been cancelled
release-please / publish-npm (push) Has been cancelled
release-please / publish-npm-backfill (push) Has been cancelled
release-please / docker (push) Has been cancelled
release-please / publish-code-scan-action (push) Has been cancelled
release-please / attest-code-scan-action (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:24:08 +08:00

104 lines
2.7 KiB
JavaScript

module.exports = (output, context) => {
// Check if trace data is available
if (!context.trace) {
// Tracing not enabled, skip trace-based checks
return true;
}
const { spans } = context.trace;
// Check for errors in any span
const errorSpans = spans.filter((s) => s.statusCode >= 400);
if (errorSpans.length > 0) {
return {
pass: false,
score: 0,
reason: `Found ${errorSpans.length} error spans`,
};
}
// Calculate total trace duration
if (spans.length > 0) {
const duration =
Math.max(...spans.map((s) => s.endTime || 0)) - Math.min(...spans.map((s) => s.startTime));
if (duration > 5000) {
// 5 seconds
return {
pass: false,
score: 0,
reason: `Trace took too long: ${duration}ms`,
};
}
}
// Check for specific operations - look for HTTP/API calls
const apiCalls = spans.filter((s) => s.name.toLowerCase().includes('http'));
if (apiCalls.length > 10) {
return {
pass: false,
score: 0,
reason: `Too many API calls: ${apiCalls.length}`,
};
}
// Verify all expected RAG steps are present
const expectedSteps = [
'query_analysis',
'document_retrieval',
'context_augmentation',
'reasoning_chain',
'response_generation',
];
const missingSteps = expectedSteps.filter((step) => !spans.some((s) => s.name === step));
if (missingSteps.length > 0) {
return {
pass: false,
score: 0,
reason: `Missing RAG workflow steps: ${missingSteps.join(', ')}`,
};
}
// Check for the main workflow span (optional - may be missing due to timing)
const workflowSpan = spans.find((s) => s.name === 'rag_agent_workflow');
if (workflowSpan) {
// Validate workflow attributes if present
const attrs = workflowSpan.attributes;
if (!attrs['workflow.success'] || attrs['workflow.success'] !== true) {
return {
pass: false,
score: 0,
reason: 'Workflow did not complete successfully',
};
}
}
// Check document retrieval performance
const retrievalSpans = spans.filter((s) => s.name.startsWith('retrieve_document_'));
if (retrievalSpans.length < 3) {
return {
pass: false,
score: 0,
reason: `Expected 3 document retrievals, found ${retrievalSpans.length}`,
};
}
// Check reasoning chain has expected sub-steps
const reasoningSteps = spans.filter((s) => s.name.startsWith('reasoning_'));
if (reasoningSteps.length < 3) {
return {
pass: false,
score: 0,
reason: `Expected at least 3 reasoning steps, found ${reasoningSteps.length}`,
};
}
// All checks passed
return {
pass: true,
score: 1,
reason: 'Trace validation successful',
};
};