import { describe, expect, it } from 'vitest'; import { researchSellPolicyRequestSchema, researchSellPolicyResponseSchema } from '../schema'; const baseRequest = { positionLotId: '550e8400-e29b-41d4-a716-446655440001', cycleId: '550e8400-e29b-41d4-a716-446655440002', evidenceId: 'evidence-1', datasetId: 'dataset-1', modelVersion: 'model-1', configVersion: 'config-1', codeSha: 'sha-1', asOf: '2026-08-01T07:00:00Z', publishedAtCutoff: '2026-08-01T06:00:00Z', currentSecurityPortfolioWeight: 0.6, currentLotPortfolioWeight: 0.2, strategicCoreFloorWeight: 0.3, hardImpairmentApproved: false, capitalFloorBreached: false, survivalSellRatioOfLot: 0, gapBelowFloorAtr: 0, consecutiveCloseBreaches: 0, cooldownSatisfied: true, concentrationSellRatioOfLot: 0, opportunityEdgeLowerBound: 0, opportunitySellRatioOfLot: 0 }; describe('research sell policy contracts', () => { it('accepts a valid point-in-time request', () => { const result = researchSellPolicyRequestSchema.safeParse(baseRequest); if (!result.success) { console.error('Validation errors:', JSON.stringify(result.error.issues, null, 2)); } expect(result.success).toBe(true); }); it('rejects a lot weight above security weight', () => { const result = researchSellPolicyRequestSchema.safeParse({ ...baseRequest, currentLotPortfolioWeight: 0.7 }); expect(result.success).toBe(false); }); it('rejects a future published-at cutoff', () => { const result = researchSellPolicyRequestSchema.safeParse({ ...baseRequest, publishedAtCutoff: '2026-08-01T08:00:00Z' }); expect(result.success).toBe(false); }); it('rejects an unknown production status', () => { const result = researchSellPolicyResponseSchema.safeParse({ action: 'Hold', sellRatioOfLot: 0, targetSecurityPortfolioWeightAfter: 0.6, policyId: 'ALG-HOLD-001', reasonCode: 'NO_SELL_CONDITION', reentryEligible: false, policyTrace: [], evidenceStatus: 'PRODUCTION' }); expect(result.success).toBe(false); }); });