T-4: M0.4b — Close sb-research.* holdout leak: 403 on dataset /export and ungranted project GETs
This commit is contained in:
parent
48ae151260
commit
5bbad5cced
1 changed files with 21 additions and 11 deletions
|
|
@ -5,9 +5,10 @@ import { Hono } from 'hono';
|
|||
import { Pool } from 'pg';
|
||||
import { getLogger, setLoggerConfig } from '@stock-bot/logger';
|
||||
import { PostgreSQLClient } from '@stock-bot/postgres';
|
||||
import type {
|
||||
CanonicalRunRequest,
|
||||
CanonicalRunResult,
|
||||
import {
|
||||
isCanonicalRunResult,
|
||||
type CanonicalRunRequest,
|
||||
type CanonicalRunResult,
|
||||
} from '@stock-bot/stock-config/canonical-research';
|
||||
import { BacktestRunner } from '../../apps/stock/orchestrator/src/backtest/BacktestRunner';
|
||||
import { PostgresBacktestRunRepository } from '../../apps/stock/orchestrator/src/backtest/PostgresBacktestRunRepository';
|
||||
|
|
@ -1285,18 +1286,18 @@ describe.skipIf(!url)('authoritative research principals and budgets', () => {
|
|||
const agentRunId = required(agentExp.trials[0]!.runId);
|
||||
await f.execute(agentRunId);
|
||||
|
||||
// Operator attaches the holdout phase run's Sharpe ratio to a finding in the agent's granted project
|
||||
// Operator attaches the holdout phase run's total return to a finding in the agent's granted project
|
||||
const opFinding = await f.research.createArtifact(
|
||||
p.project.id,
|
||||
{
|
||||
kind: 'finding',
|
||||
title: 'Operator holdout finding',
|
||||
body: 'Holdout Sharpe ratio from operator test phase',
|
||||
body: 'Holdout total return from operator test phase',
|
||||
evidence: [
|
||||
{
|
||||
runId: opRunId,
|
||||
metricsVersion: 'canonical-analytics/v1',
|
||||
metricPath: 'analytics.metrics.sharpeRatio',
|
||||
metricPath: 'analytics.metrics.totalReturn',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
@ -1307,12 +1308,12 @@ describe.skipIf(!url)('authoritative research principals and budgets', () => {
|
|||
{
|
||||
kind: 'finding',
|
||||
title: 'Agent finding',
|
||||
body: 'Sharpe ratio from agent-owned run',
|
||||
body: 'Total return from agent-owned run',
|
||||
evidence: [
|
||||
{
|
||||
runId: agentRunId,
|
||||
metricsVersion: 'canonical-analytics/v1',
|
||||
metricPath: 'analytics.metrics.sharpeRatio',
|
||||
metricPath: 'analytics.metrics.totalReturn',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
@ -1382,7 +1383,7 @@ describe.skipIf(!url)('authoritative research principals and budgets', () => {
|
|||
{
|
||||
runId: opRunId,
|
||||
metricsVersion: 'canonical-analytics/v1',
|
||||
metricPath: 'analytics.metrics.sharpeRatio',
|
||||
metricPath: 'analytics.metrics.totalReturn',
|
||||
},
|
||||
],
|
||||
}
|
||||
|
|
@ -1390,6 +1391,12 @@ describe.skipIf(!url)('authoritative research principals and budgets', () => {
|
|||
expect(forged.status).toBe(403);
|
||||
|
||||
// Operator retains full read access to the holdout finding, its retained metric, and holdout dataset hash
|
||||
const holdoutResult = await f.api.getRunResults(opRunId);
|
||||
if (!holdoutResult || !isCanonicalRunResult(holdoutResult)) {
|
||||
throw new Error('Expected canonical holdout run result');
|
||||
}
|
||||
expect(Number.isFinite(holdoutResult.analytics.metrics.totalReturn)).toBe(true);
|
||||
|
||||
const opItem = await req(`/api/v2/analysis-artifacts/${opFinding.id}`, operatorToken);
|
||||
expect(opItem.status).toBe(200);
|
||||
const opArtifact = (
|
||||
|
|
@ -1403,7 +1410,9 @@ describe.skipIf(!url)('authoritative research principals and budgets', () => {
|
|||
).artifact;
|
||||
expect(opArtifact.latestRevision.evidence[0]?.runId).toBe(opRunId);
|
||||
expect(opArtifact.latestRevision.evidence[0]?.datasetHash).toBe(holdoutDatasetHash);
|
||||
expect(Number.isFinite(opArtifact.latestRevision.evidence[0]?.value)).toBe(true);
|
||||
expect(opArtifact.latestRevision.evidence[0]?.value).toBe(
|
||||
holdoutResult.analytics.metrics.totalReturn
|
||||
);
|
||||
|
||||
expect(
|
||||
(await req(`/api/v2/analysis-artifacts/${opFinding.id}/revisions`, operatorToken)).status
|
||||
|
|
@ -1423,13 +1432,14 @@ describe.skipIf(!url)('authoritative research principals and budgets', () => {
|
|||
await f.research.reviseArtifact(
|
||||
opFinding.id,
|
||||
{
|
||||
expectedRevision: opFinding.latestRevision.ordinal,
|
||||
title: 'Sanitized finding',
|
||||
body: 'Replaced holdout reference with agent-owned run',
|
||||
evidence: [
|
||||
{
|
||||
runId: agentRunId,
|
||||
metricsVersion: 'canonical-analytics/v1',
|
||||
metricPath: 'analytics.metrics.sharpeRatio',
|
||||
metricPath: 'analytics.metrics.totalReturn',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue