import { invalidV3Input, unavailableV3Read, V3_BYTES32 } from '../../_lib/http';
import { requireV3X402Release } from '../../x402/_lib/release';

export async function GET(
  _request: Request,
  context: { params: Promise<{ mandateHash: string }> | { mandateHash: string } },
): Promise<Response> {
  const closed = requireV3X402Release();
  if (closed) return closed;
  const { mandateHash } = await context.params;
  if (!V3_BYTES32.test(mandateHash)) return invalidV3Input('invalid_mandate_hash', 'Mandate hash must be bytes32');
  return unavailableV3Read({
    route: '/api/v3/mandates/:mandateHash',
    resource: `/api/v3/mandates/${mandateHash}`,
    disposition: 'degraded',
    readiness: 'deferred',
    code: 'v3_mandate_registry_deferred',
    message: 'MandateRegistryV3 is a canonical SDK read model but is disabled by the current pilot manifest',
  });
}
